我有它<ListBox>
定製<ListBox.ItemTemplate>
和<DataTemplate>
:的DataTemplate,風格,觸發器
<ListBox>
<ListBox.ItemTemplate>
<DataTemplate>
<Border BorderBrush="Black" BorderThickness="2" CornerRadius="5">
<Image Source="{Binding Picture}" />
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
現在,當我選擇了ListBoxItem
它變得醜陋與藍色行選擇。我想改變它。我只想爲邊框的背景着色,沒有別的。我也想改變MouseOver
的行爲。我試過槽觸發器,但ContentPresenter
沒有Background屬性。
UPD:
嗯,我已經成功地改變MouseEnter
和MouseLeave
背景:
<EventTrigger RoutedEvent="Border.MouseEnter">
<BeginStoryboard>
<Storyboard >
<ColorAnimation Storyboard.TargetProperty="Background.Color"
To="LightBlue" Duration="0:0:0.03"/>
</Storyboard>
</BeginStoryboard>
</EventTrigger>
不過還是當項目的選擇不能改變Background
。我試圖通過:
<Trigger Property="ListBoxItem.IsSelected" Value="True">
<Setter Property="Background" Value="Red" />
</Trigger>
不工作
呀很好,它說: 找不到模板屬性「IsSelected」的類型「System.Windows.Controls.ContentPresenter」 – Agzam 2010-04-05 19:11:12