【问题标题】:ComponentOne DataGridColumnHeaderPresenter Style Inheritance does not work (Silverlight)ComponentOne DataGridColumnHeaderPresenter 样式继承不起作用(Silverlight)
【发布时间】:2014-01-07 03:20:25
【问题描述】:

我正在为 Silverlight 使用 ComponentOne C1DataGrid 控件。标准样式继承不起作用。 代码如下:

<UserControl x:Class="TestSLStyles.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    xmlns:c1="http://schemas.componentone.com/winfx/2006/xaml"
    xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:toolkit="http://schemas.microsoft.com/winfx/2006/xaml/presentation/toolkit"
    xmlns:sys="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib"
    mc:Ignorable="d"
    d:DesignHeight="300" d:DesignWidth="400">
    <UserControl.Resources>
        <Style x:Key="BaseStyle" TargetType="Button">
            <Setter Property="Background" Value="Yellow" />
        </Style>
        <Style x:Key="InheritedStyle" TargetType="Button" BasedOn="{StaticResource BaseStyle}">
            <Setter Property="Foreground" Value="Red" />
        </Style>

        <Style x:Key="dchpBase" x:Name="dchpBase" TargetType="c1:DataGridColumnHeaderPresenter">
            <Setter Property="Background" Value="Yellow"/>
        </Style>
        <Style x:Key="dchpInherited" x:Name="dchpInherited" TargetType="c1:DataGridColumnHeaderPresenter" BasedOn="{StaticResource dchpBase}"> 
            <Setter Property="Foreground" Value="Red"/>
        </Style>
    </UserControl.Resources>

    <StackPanel>
        <Button Content="HelloWorld" x:Name="btn1" />
        <Button Content="HelloWorld" x:Name="btn2" Style="{StaticResource BaseStyle}" />
        <Button Content="HelloWorld" x:Name="btn3" Style="{StaticResource InheritedStyle}" />

        <c1:C1DataGrid x:Name="grd1">
            <c1:C1DataGrid.Columns>
                <c1:DataGridTextColumn Header="Column1" x:Name="cln1" />
                <c1:DataGridTextColumn Header="Column2" x:Name="cln2" HeaderStyle="{StaticResource dchpBase}" />
                <c1:DataGridTextColumn Header="Column3" x:Name="cln3" HeaderStyle="{StaticResource dchpInherited}" />
            </c1:C1DataGrid.Columns>
        </c1:C1DataGrid>

    </StackPanel>
</UserControl>

正如您在下面的屏幕上看到的,此代码适用于 Button 的样式继承,但不适用于网格的列标题:

最后一列应该是黄色背景和红色前景,但基本样式没有被继承。在 Silverlight 5 和 ComponentOne 版本 4.0.20103.86 上测试

Question was posted to ComponentOne's forum as well

【问题讨论】:

标签: silverlight datagrid styles silverlight-5.0 componentone


【解决方案1】:

C1Silverlight Build 5.0.20133.381 修复了该问题

可以从以下链接下载最新版本:http://prerelease.componentone.com/hotfixes/silverlight/C1Silverlight_5.0.20141.399_RC1.msi

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2021-12-12
    • 2018-01-24
    • 1970-01-01
    • 2018-05-24
    • 2015-03-04
    • 2012-06-04
    • 2013-04-24
    • 1970-01-01
    相关资源
    最近更新 更多