1
ComboBox와 TextBox가 있고 ComboBox에서 첫 번째 항목이 선택된 경우에만 TextBox를 사용하거나 사용하지 않으려합니다.Understandig DataTrigger
이 코드는 작동합니다 (첫 번째 항목을 선택하면 비활성화)
<ComboBox SelectedIndex="{Binding Mode}">
<ComboBoxItem>Mode 1</ComboBoxItem>
<ComboBoxItem>Mode 2</ComboBoxItem>
<ComboBoxItem>Mode 3</ComboBoxItem>
</ComboBox>
<TextBox Text="{Binding ValueNotForMode1}">
<TextBox.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding ="{Binding Mode}" Value="0">
<Setter Property="TextBox.IsEnabled" Value="False"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
이 하나가 작동하지 않습니다 : (첫 번째 항목을 선택하면 사용 가능)
<ComboBox SelectedIndex="{Binding Mode}">
<ComboBoxItem>Mode 1</ComboBoxItem>
<ComboBoxItem>Mode 2</ComboBoxItem>
<ComboBoxItem>Mode 3</ComboBoxItem>
</ComboBox>
<TextBox IsEnabled="False" Text="{Binding ValueForMode1}">
<TextBox.Style>
<Style>
<Style.Triggers>
<DataTrigger Binding ="{Binding Mode}" Value="0">
<Setter Property="TextBox.IsEnabled" Value="True"/>
</DataTrigger>
</Style.Triggers>
</Style>
</TextBox.Style>
</TextBox>
가 불가능 DataTrigger를 통해 제어를 활성화하려면?
또는 트리거가 발생하지 않을 때 컨트롤을 어떻게 알 수 있습니까?
감사합니다. 첫 번째 경우에 이것이 필요하지 않은 이유를 알고 있습니까? True가 기본값이기 때문에 믿습니다. – MTR
예, 그것이 이유입니다. – LPL