WPF learning path (12) controls (Items controls), wpfitems
ListBox
Provides a list of options that can be fixed or dynamically bound
<StackPanel> <GroupBox Margin="5"> <GroupBox.Header> <TextBlock Text="Select SelectionMode"></TextBlock> </GroupBox.Header> <GroupBox.Content> <StackPanel Margin="3" Background="AliceBlue" RadioButton.Checked ="Radio_Checked"> <RadioButton Name="radioSingle">Single</RadioButton> <RadioButton Name="radioMultiple">Multiple</RadioButton> <RadioButton Name="radioExtended">Extended</RadioButton> </StackPanel> </GroupBox.Content> </GroupBox> <GroupBox Margin="5"> <GroupBox.Header> <TextBlock Text="Effect"></TextBlock> </GroupBox.Header> <GroupBox.Content> <ListBox Name="list"> <ListBoxItem>Item 1</ListBoxItem> <ListBoxItem>Item 2</ListBoxItem> <ListBoxItem>Item 3</ListBoxItem> <ListBoxItem>Item 4</ListBoxItem> <ListBoxItem>Item 5</ListBoxItem> </ListBox> </GroupBox.Content> </GroupBox></StackPanel>
private void Radio_Checked(object sender, RoutedEventArgs e){ RadioButton btn = (RadioButton)e.OriginalSource; string mode = btn.Name; switch (mode) { case "radioSingle": list.SelectionMode = SelectionMode.Single; break; case "radioMultiple": list.SelectionMode = SelectionMode.Multiple; break; case "radioExtended": list.SelectionMode = SelectionMode.Extended; break; }}
More
Http://blog.csdn.net/samsone/article/details/7195365
Https://msdn.microsoft.com/en-us/library/system.windows.controls.listbox (v = vs.110). aspx
ComboBox
Allows you to select an Item in the list, define the DropDownOpened/DropDownClosed event, and perform corresponding operations when opening or closing the drop-down list
<Grid> <Grid.RowDefinitions> <RowDefinition /> <RowDefinition /> </Grid.RowDefinitions> <TextBlock Grid.Row="0" Text="Summary" HorizontalAlignment="Center" VerticalAlignment="Center" FontSize="20" /> <ComboBox Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Center"> <StackPanel Orientation="Horizontal" Margin="5"> <StackPanel Width="200"> <TextBlock Margin="5" FontSize="15" FontWeight="Bold" VerticalAlignment="Center" Text="Item A" /> <TextBlock Margin="5" FontSize="10" TextWrapping="Wrap"> This is a text introduction about Item A. ...... End </TextBlock> </StackPanel> </StackPanel> <StackPanel Orientation="Horizontal" Margin="5"> <StackPanel Width="200"> <TextBlock Margin="5" FontSize="15" FontWeight="Bold" VerticalAlignment="Center" Text="Item B" /> <TextBlock Margin="5" FontSize="10" TextWrapping="Wrap"> ...</TextBlock> </StackPanel> </StackPanel> <StackPanel Orientation="Horizontal" Margin="5"> <StackPanel Width="200"> <TextBlock Margin="5" FontSize="15" FontWeight="Bold" VerticalAlignment="Center" Text="Item C" /> <TextBlock Margin="5" FontSize="10" TextWrapping="Wrap"> ...</TextBlock> </StackPanel> </StackPanel> </ComboBox> </Grid>
Scroll bar settings
<ComboBox Grid. Row = "1" HorizontalAlignment = "Stretch" verticalignment = "Center" ScrollViewer. CanContentScroll = "false">
More
Http://blog.csdn.net/tcjiaan/article/details/6941601
Https://msdn.microsoft.com/en-us/library/system.windows.controls.combobox (v = vs.110). aspx
Menu
It has been used in the previous WordPad program.
More
Http://www.th7.cn/Program/WPF/201301/122256.shtml
To be continue...