WPF学习之路(十二)控件(Items控件)_.NET_编程开发_程序员俱乐部

中国优秀的程序员网站程序员频道CXYCLUB技术地图
热搜:
更多>>
 
您所在的位置: 程序员俱乐部 > 编程开发 > .NET > WPF学习之路(十二)控件(Items控件)

WPF学习之路(十二)控件(Items控件)

 2015/4/23 10:04:08  alex_cool  程序员俱乐部  我要评论(0)
  • 摘要:ListBox提供了一个选项列表,可以固定或者动态绑定<StackPanel><GroupBoxMargin="5"><GroupBox.Header><TextBlockText="SelectSelectionMode"></TextBlock></GroupBox.Header><GroupBox.Content><
  • 标签:学习 item 控件

 

 ListBox

 提供了一个选项列表,可以固定或者动态绑定

<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;
    }

}

 

 更多内容

http://blog.csdn.net/samsone/article/details/7195365

https://msdn.microsoft.com/en-us/library/system.windows.controls.listbox(v=vs.110).aspx

 

 

ComboBox

 允许用户在列表中选择一个Item,定义了DropDownOpened/DropDownClosed事件,打开或关闭下拉列表时执行对应的操作

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

 

滚动条设置

 <ComboBox Grid.Row="1" HorizontalAlignment="Stretch" VerticalAlignment="Center" ScrollViewer.CanContentScroll="false">

 

 

更多内容

http://blog.csdn.net/tcjiaan/article/details/6941601

https://msdn.microsoft.com/en-us/library/system.windows.controls.combobox(v=vs.110).aspx

 

 

Menu

 在之前的写字板程序中已经有过应用

 

更多内容

http://www.th7.cn/Program/WPF/201301/122256.shtml

 

 

 

 

 

 

To be continue...

发表评论
用户名: 匿名