Fill up the ListBox with brush names : Brush « Windows Presentation Foundation « VB.Net

Home
VB.Net
1.2D
2.Application
3.Class
4.Data Structure
5.Data Types
6.Database ADO.net
7.Development
8.Event
9.File Directory
10.Generics
11.GUI
12.Language Basics
13.LINQ
14.Network Remote
15.Security
16.Thread
17.Windows Presentation Foundation
18.Windows System
19.XML
20.XML LINQ
VB.Net Tutorial
VB.Net by API
VB.Net » Windows Presentation Foundation » BrushScreenshots 
Fill up the ListBox with brush names
Fill up the ListBox with brush names
      


<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        x:Class="WpfApplication1.CompileXamlWindow"
        Title="Compile XAML Window" 
        SizeToContent="WidthAndHeight" 
        ResizeMode="CanMinimize">
    <StackPanel>
        <Button HorizontalAlignment="Center" Margin="24" Click="ButtonOnClick">
            Click
        </Button>
        <Ellipse Name="elips" Width="200" Height="100" Margin="24" Stroke="Black"/>
        <ListBox Name="lstbox" Width="150" Height="150" Margin="24" SelectionChanged="ListBoxOnSelection" />
    </StackPanel>
</Window>
//File:Window.xaml.vb
Imports System
Imports System.Reflection
Imports System.Windows
Imports System.Windows.Controls
Imports System.Windows.Input
Imports System.Windows.Media

Namespace WpfApplication1
  Public Partial Class CompileXamlWindow
    Inherits Window

    Public Sub New()
      InitializeComponent()

      For Each prop As PropertyInfo In GetType(Brushes).GetProperties()
        lstbox.Items.Add(prop.Name)
      Next
    End Sub
    Private Sub ButtonOnClick(sender As Object, args As RoutedEventArgs)
      Dim btn As Button = TryCast(sender, Button)
      MessageBox.Show(Convert.ToString(btn.Content"' has been clicked.")
    End Sub
    Private Sub ListBoxOnSelection(sender As Object, args As SelectionChangedEventArgs)
      Dim lstbox As ListBox = TryCast(sender, ListBox)
      Dim strItem As String = TryCast(lstbox.SelectedItem, String)
      Dim prop As PropertyInfo = GetType(Brushes).GetProperty(strItem)
      elips.Fill = DirectCast(prop.GetValue(Nothing, Nothing), Brush)
    End Sub
  End Class
End Namespace

   
    
    
    
    
    
  
Related examples in the same category
1.Fill = Brushes.RedFill = Brushes.Red
2.Fill = new SolidColorBrush(Colors.Green)Fill = new SolidColorBrush(Colors.Green)
3.Fill = new SolidColorBrush(Color.FromRgb(0, 0, 255))Fill = new SolidColorBrush(Color.FromRgb(0, 0, 255))
4.Fill = new SolidColorBrush(Color.FromArgb(100, 0, 0, 255));Fill = new SolidColorBrush(Color.FromArgb(100, 0, 0, 255));
5.Using the SolidColorBrush typeUsing the SolidColorBrush type
6.Using the SolidColorBrush and Color typeUsing the SolidColorBrush and Color type
7.Describes the brush's color using ARGB values. Each value has a range of 0-255.Describes the brush's color using ARGB values. Each value has a range of 0-255.
8.Shows the predefined brushes defined by the System.Brushes class.Shows the predefined brushes defined by the System.Brushes class.
9.Drawing Brush In XAMLDrawing Brush In XAML
10.Use SolidColorBrush to paint RectangleUse SolidColorBrush to paint Rectangle
11.Solid brush using type converterSolid brush using type converter
12.Fill the underline decoration with a solid color brush in VBFill the underline decoration with a solid color brush in VB
13.Fill the strikethrough decoration with a solid color brush in VBFill the strikethrough decoration with a solid color brush in VB
14.Colors and BrushesColors and Brushes
15.Predefined brush in Brushes ClassPredefined brush in Brushes Class
16.Convert contents of a ListBoxItem to an instance of Thickness by using the BrushConverterConvert contents of a ListBoxItem to an instance of Thickness by using the BrushConverter
17.Solid Color Brush In Code with predefined brushSolid Color Brush In Code with predefined brush
18.Solid Color Brush In Code with SolidColorBrushSolid Color Brush In Code with SolidColorBrush
19.Solid Color Brush In Code with SolidColorBrush and RGB colorSolid Color Brush In Code with SolidColorBrush and RGB color
20.DrawingBrush with DrawingGroupDrawingBrush with DrawingGroup
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.