2
這裏是XAML的代碼:IsMouseOver引發不工作的GridViewColumn WPF XAML
<Page.Resources>
<Style x:Key="cells" TargetType="GridViewColumnHeader">
<Style.Triggers>
<Trigger Property="IsEnabled" Value="True">
<Setter Property="Background" Value="#FF00B9FF"></Setter>
<Setter Property="Foreground" Value="White"></Setter>
<Setter Property="BorderBrush" Value="#FF00B9FF"></Setter>
<Setter Property="Padding" Value="8"></Setter>
<Setter Property="MinWidth" Value="100"></Setter>
</Trigger>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Background" Value="#FF00B9FF"></Setter>
<Setter Property="Foreground" Value="White"></Setter>
<Setter Property="BorderBrush" Value="#FF00B9FF"></Setter>
<Setter Property="Padding" Value="2"></Setter>
<Setter Property="MinWidth" Value="100"></Setter>
</Trigger>
</Style.Triggers>
</Style>
</Page.Resources>
<Grid>
<Label Content="Notifications" VerticalAlignment="Top" HorizontalAlignment="Left" FontSize="20"></Label>
<ListView Background="{x:Null}" FontSize="17" Margin="0,30,0,0" ItemsSource="{Binding Notifications}" HorizontalAlignment="Center" BorderBrush="{x:Null}">
<ListView.View>
<GridView AllowsColumnReorder="False">
<GridViewColumn Header="Sl No." DisplayMemberBinding="{Binding Slno}" HeaderContainerStyle="{StaticResource cells}"></GridViewColumn>
<GridViewColumn Header="Message" DisplayMemberBinding="{Binding Message}" HeaderContainerStyle="{StaticResource cells}"></GridViewColumn>
<GridViewColumn Header="Date" DisplayMemberBinding="{Binding Date}" HeaderContainerStyle="{StaticResource cells}"></GridViewColumn>
</GridView>
</ListView.View>
</ListView>
</Grid>
的IsEnabled
觸發器是不錯,但IsMouseOver
觸發不起作用。我試圖使用ControlTemplate
,但沒有<GridViewColumn/>
的屬性,並返回錯誤Cannot convert ControlTemplate type to DataTemplate or Style
。
我想改變我的網格標題的樣式,當在默認模板顯示MOuseOver時。
我該如何重寫樣式?
請幫助我。 –
從http://stackoverflow.com/questions/1172534/wpf-gridviewheader-styling-questions得到了我的問題的答案 –