0
は、私はアイテムはリスト項目のソースを使ってC#で動的に設定されている動的コンボボックスアイテムにスタイルを適用するにはどうすればよいですか?
<ComboBox x:Name="comboBox1" Style="{StaticResource ComboBoxBlue}" HorizontalAlignment="Left" Margin="10,128,0,0" VerticalAlignment="Top" Width="75" />
TargetTypeにトグルボタンのスタイルを設定したコンボボックスを持っている
public static List<string> MyItemSource = new List<string>()
{
"Item 1", "Item 2", "Item 3", "Item 4"
};
comboBox1.ItemsSource = MyItemSource;
設定項目の背景色(グローバル)
<!-- ComboBox Blue Item -->
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="Foreground" Value="White" />
<Setter Property="Background" Value="Blue" />
<Setter Property="BorderBrush" Value="Blue" />
</Style>
しかし、どのコンボボックスにのみ適用されるようにx:Keyを設定するのですか?
<Style x:Key="ComboBoxBlueItem" TargetType="{x:Type ComboBoxItem}">
私は、各コンボボックスにComboBox.ItemContainerStyleタグを使用することができ、その後私は、個別に各1のスタイルを設定する必要があります。
<ComboBox.ItemContainerStyle>
<Style TargetType="{x:Type ComboBoxItem}">
<Setter Property="Background" Value="Blue" />
</Style>
</ComboBox.ItemContainerStyle>
それを解決した、ありがとう –