Hello all! I am new to VB and I am working on some code that is a painter. I have posted the xaml and vb portions bellow. I am getting error codes I do not understand. in line 84, 85, and 86 of the vb code it is not recognizing redSlider, blueSlide, ect. There is also an error code saying painter.Application is not deffined. Thanks in advance for the insight!

<Window x:Class="Painter"
   Title="Painter" Height="573" Width="350" Background="LightBlue">

      <Style x:Key="ColorStyle">
         <Setter Property="Slider.Width" Value="150" />
         <Setter Property="Slider.Minimum" Value="0" />
         <Setter Property="Slider.Maximum" Value="255" />
         <Setter Property="Slider.IsSnapToTickEnabled" Value="True" />
         <Setter Property="Slider.VerticalAlignment" Value="Center" />
         <Setter Property="Slider.HorizontalAlignment" Value="Center" />
         <Setter Property="Slider.Value" Value="0" />
         <Setter Property="Slider.AutoToolTipPlacement"                 
            Value="TopLeft" />

         <EventSetter Event="Slider.ValueChanged"                       
            Handler="slider_ValueChanged" />


         <ColumnDefinition Width="Auto" /> 
         <ColumnDefinition Width="*" />

      <Canvas Grid.Column="1" Margin="0" Name="paintCanvas" 
         Background="White" />

      <StackPanel Margin="3"> 

         <GroupBox Grid.ColumnSpan="1" Header="Color" Margin="3" 
            Name="colorGroupBox" HorizontalAlignment="Stretch" 
            <StackPanel Name="colorStackPanel" Margin="3" 
               HorizontalAlignment="Left" VerticalAlignment="Top">

               <Label HorizontalAlignment="Center" VerticalAlignment="Center">Red</Label>
               <Slider Name="redSlider" Style="{StaticResource ColorStyle}"  /> 
               <Label HorizontalAlignment="Center" VerticalAlignment="Center">Green</Label>   
               <Slider Name="greenSlider" Style="{StaticResource ColorStyle}" />
               <Label HorizontalAlignment="Center" VerticalAlignment="Center">Blue</Label>
               <Slider Name="blueSlider" Style="{StaticResource ColorStyle}" />
               <Label HorizontalAlignment="Center" VerticalAlignment="Center">Alpha</Label>
               <Slider Name="alphaSlider" Style="{StaticResource ColorStyle}" />

               <Label Name="colorLabel" Grid.RowSpan="4" Grid.Column="2" 
         Margin="20" Height="83" />


         <GroupBox Header="Size" Name="sizeGroupBox" Margin="3">
            <StackPanel Name="StackPanel1" Margin="3">
               <RadioButton Name="smallRadioButton" Margin="3">
               <RadioButton Name="mediumRadioButton" Margin="3" 
               <RadioButton Name="largeRadioButton" Margin="3">

         <Button Height="23" Name="undoButton" Width="75" 

         <Button Height="23" Name="clearButton" Width="75" 
Class Painter
    Private diameter As Integer = 8
    Private brushColor As Brush = Brushes.Black
    Private shouldErase As Boolean = False
    Private shouldPaint As Boolean = False

    Private Enum Sizes
        SMALL = 4
        MEDIUM = 8
        LARGE = 10
    End Enum

    Private Sub PaintCircle(ByVal circleColor As Brush, _
       ByVal position As Point)

        Dim newEllipse As Ellipse = New Ellipse()

        newEllipse.Fill = circleColor
        newEllipse.Width = diameter
        newEllipse.Height = diameter

        Canvas.SetTop(newEllipse, position.Y)
        Canvas.SetLeft(newEllipse, position.X)

    End Sub ' 

    Private Sub paintCanvas_MouseLeftButtonDown(ByVal sender As Object, _
       ByVal e As MouseButtonEventArgs) _
       Handles paintCanvas.MouseLeftButtonDown

        shouldPaint = True
    End Sub

    Private Sub paintCanvas_MouseLeftButtonUp(ByVal sender As Object, _
       ByVal e As MouseButtonEventArgs) _
       Handles paintCanvas.MouseLeftButtonUp

        shouldPaint = False
    End Sub

    Private Sub paintCanvas_MouseMove(ByVal sender As Object, _
       ByVal e As MouseEventArgs) _
       Handles paintCanvas.MouseMove

        If shouldPaint = True Then

            Dim mousePosition As Point = e.GetPosition(paintCanvas)
            PaintCircle(brushColor, mousePosition)
        ElseIf shouldErase = True Then

            Dim mousePosition As Point = e.GetPosition(paintCanvas)
            PaintCircle(paintCanvas.Background, mousePosition)
        End If
    End Sub

    Private Sub paintCanvas_MouseRightButtonDown(ByVal sender As Object, _
       ByVal e As MouseButtonEventArgs) _
       Handles paintCanvas.MouseRightButtonDown

        shouldErase = True
    End Sub

    Private Sub paintCanvas_MouseRightButtonUp(ByVal sender As Object, _
       ByVal e As MouseButtonEventArgs) _
       Handles paintCanvas.MouseRightButtonUp

        shouldErase = False
    End Sub

    Class Painter
        Private Sub slider_ValueChanged(ByVal sender As Object, _
           ByVal e As RoutedPropertyChangedEventArgs(Of Double))

            Dim backgroundColor As New SolidColorBrush()
            backgroundColor.Color = Color.FromArgb(CByte(alphaSlider.Value), _
               CByte(redSlider.Value), CByte(greenSlider.Value), _

            colorLabel.Background = backgroundColor
        End Sub
    End Class

    Private Sub smallRadioButton_Checked(ByVal sender As Object, _
       ByVal e As RoutedEventArgs) Handles smallRadioButton.Checked

        diameter = Sizes.SMALL
    End Sub

    Private Sub mediumRadioButton_Checked(ByVal sender As Object, _
       ByVal e As RoutedEventArgs) Handles mediumRadioButton.Checked

        diameter = Sizes.MEDIUM
    End Sub

    Private Sub largeRadioButton_Checked(ByVal sender As Object, _
       ByVal e As RoutedEventArgs) Handles largeRadioButton.Checked

        diameter = Sizes.LARGE
    End Sub

    Private Sub undoButton_Click(ByVal sender As Object, _
       ByVal e As RoutedEventArgs) Handles undoButton.Click

        If paintCanvas.Children.Count > 0 Then

            paintCanvas.Children.RemoveAt(paintCanvas.Children.Count - 1)
        End If
    End Sub

    Private Sub clearButton_Click(ByVal sender As Object, _
       ByVal e As RoutedEventArgs) Handles clearButton.Click

    End Sub
End Class
6 Years
Discussion Span
Last Post by jtodd

I think they are deffinded in the xaml code lines 52-59. Am I missing something?

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.