【发布时间】:2018-04-18 07:29:12
【问题描述】:
我的 Xaml 代码
<ComboBox HorizontalContentAlignment="Left"
x:Name="Stat"
IsEditable="True"
Width="247"
HorizontalAlignment="Left"
IsReadOnly="True"
ItemsSource="{Binding OrderStatus,Mode=TwoWay}"
Text="{Binding StatusSelectedValue}"
Height="26">
<ComboBox.ItemTemplate>
<DataTemplate>
<CheckBox Content="{Binding Description}"
IsChecked="{Binding IsChecked}"
Checked="CheckBox_Checked"
Unchecked="CheckBox_Unchecked"/>
</DataTemplate>
</ComboBox.ItemTemplate>
</ComboBox>
xaml.cs
//当项目被选中或取消选中时,我想更新我的多选组合框上显示的文本
private void CheckBox_Checked(object sender, RoutedEventArgs e)
{
var selectedItem = sender as CheckBox ;
var r= selectedNode.IsChecked.Value;
//尝试获取所有选中项的值并将其连接并在组合框中显示类似于下面的内容
Stat.Text = String.Join(",",selectedItemValues.toArray());//this line of code is for example only for what i want to do
}
非常感谢任何 mvvm 方式或 xaml.cs 方式的帮助。
【问题讨论】: