我有以下情况
1- xaml 中的组合框
<ComboBox
x:Name="PublishableCbo" Width="150" IsEnabled="True" HorizontalAlignment="Left" Height="20"
SelectedValue="{Binding Path=Published, Mode=TwoWay}"
Grid.Column="6" Grid.Row="0">
<ComboBox.Items>
<ComboBoxItem Content="All" IsSelected="True" />
<ComboBoxItem Content="Yes" />
<ComboBoxItem Content="No" />
</ComboBox.Items>
2- 在模型类中,我定义了一个属性并绑定到组合框中的选定值
public bool Published
{
get
{
return _published;
}
set
{
_published = value;
OnPropertyChanged("Published");
}
}
我知道我必须实现一个转换器,但不知道具体如何。What I want is when a select Yes/No, in the model get a True/false value, when "all" is selected, to get null value.