1
所以我试图改变ComboBox的边框颜色AFTER用户选择了一个Item。 (从红到绿/灰/ AnyOtherColor)SelectionChanged事件在选择之前触发
问题:德恩我运行代码,事件似乎火之前用户已经做出选择。
我的组合框是在多个网格内,并使用ResourceDictionary进行样式设置(我将在一秒内显示代码)。
我在缺乏更好的知识的情况下研究了SelectionChanged事件。
XAML组合框:
<ComboBox Grid.Column="1"
Grid.Row="1"
Style="{StaticResource FormComboBox}"
x:Name="comboAnrede"
SelectionChanged="ComboBox_SelectionChanged" >
<ComboBoxItem Content="Keine Angabe"
IsSelected="True"/>
<ComboBoxItem Content="Dr." />
<ComboBoxItem Content="Prof." />
<ComboBoxItem Content="Prof. Dr." />
<ComboBoxItem Content="Mag." />
<ComboBoxItem Content="Ing." />
<ComboBoxItem Content="Ba." />
</ComboBox>
代码隐藏
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
comboAnrede.BorderBrush = new SolidColorBrush(new Color { R = 204, G = 204, B = 204, A = byte.MaxValue });
}
资源词典
<Style TargetType="ComboBox" x:Key="FormComboBox">
<Setter Property="Margin" Value="10,0" />
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="VerticalAlignment" Value="Center" />
<Setter Property="BorderBrush" Value="Red" />
<Setter Property="BorderThickness" Value="0,0,0,1" />
</Style>
不任何人都知道我可以如何等待实际选择? (如果可能,你是否可以尝试向我解释是否以及何时可以重复使用与其他组合框相同的事件?)