我从我的 App.xaml 中引用 ExpressionDark.xaml,它工作正常,但是当我尝试在 ItemsControl 中使用 ItemContainerStyle 时,ItemsControl 中的项目恢复为基本样式。
<ItemsControl Grid.Column="1" VerticalAlignment="Center" Margin="10">
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="Margin" Value="5" />
</Style>
</ItemsControl.ItemContainerStyle>
<ItemsControl.Items>
<TextBlock Text="{Binding Error}" />
<TextBox Text="{Binding Path=Username,UpdateSourceTrigger=PropertyChanged,ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{StaticResource validationTemplate}"></TextBox>
<TextBox Text="{Binding Path=Password,UpdateSourceTrigger=PropertyChanged,ValidatesOnDataErrors=True}" Validation.ErrorTemplate="{StaticResource validationTemplate}"></TextBox>
<Button VerticalAlignment="Center" HorizontalAlignment="Right" Command="{Binding SignInCommand}" IsEnabled="{Binding CanSignIn}" Content="Sign In"></Button>
<TextBox Text="{Binding Path=Username}"></TextBox>
</ItemsControl.Items>
</ItemsControl>
我只是想为垂直样式找到一个好的控件(轻松地在项目之间添加边距),所以也许有一种更好的方法不会覆盖 App.xaml 中指定的样式。
TIA