SmartComboBox绑定Text还是绑定SelectedValue

一、Text 使用情景:
1.于可以手功录入值的情况。例如可选为:A、B、C 但录入时可能录入"D" (要配合IsFilteringEnabled使用

        <s:SmartLabel Caption="類別" IsRequired="True">
            <s:SmartComboBox Text="{Binding Type, Mode=TwoWay}" IsEditable="True" IsFilteringEnabled="false">
                <sys:String>班車</sys:String>
                <sys:String>租車</sys:String>
                <sys:String>其他</sys:String>
            </s:SmartComboBox>
        </s:SmartLabel>

2.备选项只有一列
<s:SmartComboBox Text="{Binding Currency, Mode=TwoWay}" ItemsSource="{Binding Source={StaticResource CurrencyItems}, Path=View}" />

3.备选项有多
        <s:SmartLabel Caption="補假日期">
            <s:SmartComboBox Text="{Binding OffsetDate, Mode=TwoWay, StringFormat=yyyy-MM-dd, Converter={x:Static s:Converter.StringToDateConverter}, UpdateSourceTrigger=LostFocus}"
                             IsEditable="True"
                             IsFilteringEnabled="False"
                             ItemsSource="{Binding DataContext.StaffOTDates, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=s:EditorPage}}"
                             telerik:TextSearch.TextPath="OTDate">
                <!--  用Template顯示兩列  -->
                <s:SmartComboBox.ItemTemplate>
                    <DataTemplate>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition />
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <TextBlock Text="{Binding OTDate, StringFormat=yyyy-MM-dd}" />
                            <TextBlock Grid.Column="1" Text="{Binding RecessType}" />
                        </Grid>
                    </DataTemplate>
                </s:SmartComboBox.ItemTemplate>
            </s:SmartComboBox>
        </s:SmartLabel>

二、SelectedValue使用情景
1. 用于通过字段关联显示另一表字段(有点类DBLookUpComboBox的影子

<s:SmartLabel Caption="默认价码">
		<s:SmartComboBox Text="{Binding aRateCode, Mode=TwoWay}"
			ItemsSource="{Binding Source={StaticResource HTLRateItems}, Path=List}"
			DisplayMemberPath="RateCode"
			SelectedValue="{Binding RateID, Mode=TwoWay}"
			SelectedValuePath="ID" />
	</s:SmartLabel>



评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值