WPF learning path (12) controls (Items controls), wpfitems

Source: Internet
Author: User

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...

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.