Tosker

ComboBox Tutorial Finished

Jan 13th, 2017
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
XML 2.50 KB | None | 0 0
  1. <!-- ToskersCorner.com -->
  2.     <Grid>
  3.         <!-- Grid Definitions-->
  4.         <Grid.RowDefinitions>
  5.             <RowDefinition/>
  6.             <RowDefinition/>
  7.         </Grid.RowDefinitions>
  8.         <Grid.ColumnDefinitions>
  9.             <ColumnDefinition/>
  10.             <ColumnDefinition/>
  11.         </Grid.ColumnDefinitions>
  12.  
  13.         <!--ComboBox XAML-->
  14.         <StackPanel Grid.Row="0" Grid.Column="0" Margin="5">
  15.             <TextBlock>XAML Items</TextBlock>
  16.             <ComboBox>
  17.                 <ComboBoxItem>
  18.                     Item 1
  19.                 </ComboBoxItem>
  20.                 <ComboBoxItem>
  21.                     <TextBlock>Item 2</TextBlock>
  22.                 </ComboBoxItem>
  23.                 <ComboBoxItem>
  24.                     <StackPanel Orientation="Horizontal">
  25.                         <Ellipse Width="15" Height="15" Fill="Red"/>
  26.                         <TextBlock>Red Item</TextBlock>
  27.                     </StackPanel>
  28.                 </ComboBoxItem>
  29.             </ComboBox>
  30.         </StackPanel>
  31.  
  32.         <!--ComboBox Items Source-->
  33.         <StackPanel Grid.Row="0" Grid.Column="1" Margin="5">
  34.             <TextBlock>Names</TextBlock>
  35.             <ComboBox ItemsSource="{Binding NameCollection}"/>
  36.             <TextBlock>Colors</TextBlock>
  37.             <ComboBox ItemsSource="{Binding BrushCollection}"/>
  38.         </StackPanel>
  39.  
  40.         <!--ComboBox Item Template-->
  41.         <StackPanel Grid.Row="1" Grid.Column="0" Margin="5">
  42.             <TextBlock>Templated Colors</TextBlock>
  43.             <ComboBox ItemsSource="{Binding BrushCollection}">
  44.                 <ComboBox.ItemTemplate>
  45.                     <DataTemplate>
  46.                         <Ellipse Width="15" Height="15" Fill="{Binding}"/>
  47.                     </DataTemplate>
  48.                 </ComboBox.ItemTemplate>
  49.             </ComboBox>
  50.         </StackPanel>
  51.  
  52.         <!--ComboBox Selection-->
  53.         <StackPanel Grid.Row="1" Grid.Column="1" Margin="5">
  54.             <TextBlock>Cursor Styles</TextBlock>
  55.             <ComboBox Cursor="Hand">
  56.                 <ComboBox.ItemContainerStyle>
  57.                     <Style TargetType="ComboBoxItem">
  58.                         <Setter Property="Cursor" Value="Pen"/>
  59.                     </Style>
  60.                 </ComboBox.ItemContainerStyle>
  61.                 <ComboBoxItem>
  62.                     Item 1
  63.                 </ComboBoxItem>
  64.                 <ComboBoxItem>
  65.                     Item 2
  66.                 </ComboBoxItem>
  67.             </ComboBox>
  68.         </StackPanel>
  69.     </Grid>
Add Comment
Please, Sign In to add comment