WPF界面中控件及其属性用法(三)【ComboBox】

ComboBox控件效果图:

 

主要代码:

<TextBlock Grid.Column="0" Grid.Row="0" 

           Style="{StaticResource TextBlockStretchStyle}">

            <Run Foreground="Red">*</Run>

            <Run>序号:</Run>

</TextBlock>

  <telerik:RadBusyIndicator Grid.Row="0" Grid.Column="1"

           IsBusy="{Binding Path=IsBusy,Mode=TwoWay}"

           BusyContent="加载信息"  

           Style="{StaticResource ResourceKey=RadBusyIndicatorStretchStyle}"

    >

       <telerik:RadComboBox  TabIndex="0" 

                             x:Name="VoyageComboBox"  ToolTip="请选择编号" 

                             SelectedValue ="{Binding Path=,Mode=TwoWay}" 

                             SelectedValuePath="ID"

                             ItemsSource="{Binding Voyage,Mode=TwoWay}"

                             DisplayMemberPath="Name"

                             IsEditable="True"

                             OpenDropDownOnFocus="True"

                             CanAutocompleteSelectItems="True"

                             IsFilteringEnabled="True"

                             CanKeyboardNavigationSelectItems="True"

                             IsTextSearchEnabled="True"

                             TextSearchMode="Contains"

                             Beh:FocusExtension.IsFocused="{Binding Focus}"  

                             BorderBrush="{Binding Brush}

                             >

 <EventsBinding:EventBinder.Mappings>

    <EventsBinding:CommandEvent Event="LostFocus"

                   Command="{Binding  LostFocus}"

                   CommandParameter="{Binding ComboBox }" />

    <EventsBinding:CommandEvent Event="SelectionChanged" 

                   Command="{Binding  Selected}" 

                   CommandParameter="{Binding ElementName=ComboBox}" />

  </EventsBinding:EventBinder.Mappings>

 </telerik:RadComboBox>

</telerik:RadBusyIndicator>

对用到的一些属性进行解释:

① SelectedValue   绑定选中的一个信息.

② SelectedValuePath  根据***选择该值.

③ ItemSource  绑定控件下拉的所有信息.

④ DisPlayMemberPath   根据***显示下拉信息.

⑤ IsEditable     是否可编辑。

⑥ OpenDropDownOnFocus    打开时是否显示下拉框。

⑦ CanAutocompleteSelectItems  能否自动补全。

⑧ CanKeyboaedNavigationSelectItems   是否允许键盘输入匹配选择。

⑨ IsTextSearchEnabled   是否文本可以选择。

⑩ TextSearchMode   文本选择模式。

 Beh:FocusExtension.IsFocused    绑定控件聚焦时触发事件。

 BorderBrush        绑定控件的边框颜色。

下面事件中有LostFocus和SelectionChanged分别绑定控件失去焦点时触发的事件和绑定选择某一个信息时触发的事件。

posted @ 2013-05-07 16:59  Latent_Truth  阅读(1226)  评论(0)    收藏  举报