第一个GridViewColumnHeader没有接收自定义GridViewColumnHeaderStyle

时间:2013-11-28 01:09:04

标签: c# wpf xaml

我一直在开发一个Wpf项目,它包含一个DfcListView类(继承自ListView类)。在'DfcListView.xaml'文件中,我有以下代码来定义DfcListViewGridViewColumnHeaderStyle(GridViewColumnHeader样式):

<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:local="clr-namespace:DataFlowControls">

    <Style x:Key="DfcListViewGridViewColumnHeaderGripperStyle" TargetType="{x:Type Thumb}"></Style>
    <Style x:Key="DfcListViewGridViewColumnHeaderStyle" TargetType="{x:Type GridViewColumnHeader}"></Style>

</ResourceDictionary>

然后,在xaml文件'Generic.xaml'中,我有:

<ResourceDictionary
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:local="clr-namespace:DataFlowControls">    

    <ResourceDictionary.MergedDictionaries>        
        <ResourceDictionary Source="/DataFlowControls;component/Themes/DfcEditCheckBox.xaml" />
        <ResourceDictionary Source="/DataFlowControls;component/Themes/DfcEditComboBox.xaml" />
        <ResourceDictionary Source="/DataFlowControls;component/Themes/DfcEditTextBox.xaml" />
        <ResourceDictionary Source="/DataFlowControls;component/Themes/DfcListview.xaml" />
    </ResourceDictionary.MergedDictionaries>

</ResourceDictionary>

此代码工作正常,但结果DfcListView中的第一个GridViewColumnHeader没有收到DfcListViewGridViewColumnHeaderStyle。所有其他网格视图列标题都接收DfcListViewGridViewColumnHeaderStyle。 我如何修改代码,以便第一个GridViewColumnHeader还接收DfcListViewGridViewColumnHeaderStyle?

我已经在stackoverflow.com上阅读了关于这些问题的一些其他文章,我无法从中确定解决方案。

1 个答案:

答案 0 :(得分:0)

我刚刚知道如果我从代码中删除以下代码(参见上面的代码),它就可以了:

X:键= “DfcListViewGridViewColumnHeaderStyle”