【发布时间】:2014-07-22 14:06:53
【问题描述】:
我正在使用 MVVM conceot 来开发我的项目。 我有组合框和文本框的视图,我希望仅在选择组合框的特定项目时启用文本框。组合框的项目源绑定到字符串列表,我要做的就是选择列表的第四个元素“其他”时启用文本框,否则禁用。 在视图中,我有
<ComboBox x:Name="department_Combobox" HorizontalAlignment="Left"
ItemsSource=" {Binding Path= DepartmentList}" SelectedItem="{Binding Department}"
VerticalAlignment="Top" Width="200" Height="25" SelectedIndex="0" Grid.Row="17"
Grid.RowSpan="2" Grid.Column="1" >
</ComboBox>
<TextBox x:Name="department_Name_TextBox" Text="{Binding
Path=Department,Mode=TwoWay}" Grid.Row="17" TextWrapping="Wrap" Grid.Column="2"
Width="201" Height="24" VerticalAlignment="Center" HorizontalAlignment="Right" />
如何在仅选择 Departmentlist 的第 4 个列表时启用文本框,并在选择其他元素时禁用文本框? 谢谢。
【问题讨论】:
-
看起来使用触发器比使用绑定更好。