首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >将样式用于网格视图

将样式用于网格视图
EN

Stack Overflow用户
提问于 2011-07-29 21:39:59
回答 1查看 274关注 0票数 0

如何在gridview中使用以下样式

代码语言:javascript
复制
<Stylex:Key="{x:TypeCustom:DataGridRowHeader}"TargetType="{x:TypeCustom:DataGridRowHeader}">
<SetterProperty="Background"Value="{StaticResource RowHeaderBackgroundBrush}" />     
<SetterProperty="Template">
    <Setter.Value>
        <ControlTemplate TargetType="{x:TypeCustom:DataGridRowHeader}">
            <Grid>                       
                <Custom:DataGridHeaderBorder IsSelected="{TemplateBinding IsRowSelected}"
                             IsHovered ="{TemplateBinding IsMouseOver}"
                             IsPressed="{TemplateBinding IsPressed}"
                             BorderBrush="{Binding RelativeSource={RelativeSource AncestorType={x:Type Custom:DataGrid}},
                                Path=HorizontalGridLinesBrush}"
                             Background="{TemplateBinding Background}"                                    
                             BorderThickness="0,1,0,0"
                             Padding ="{TemplateBinding Padding}"
                             Orientation="Horizontal"
                             SeparatorVisibility="{TemplateBinding SeparatorVisibility}"
                             SeparatorBrush="{TemplateBinding SeparatorBrush}" Margin="0,-1,0,0">

                    <StackPanel Orientation="Horizontal">
                        <ContentPresenter SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"
                                          VerticalAlignment="Center"/>
                        <Control SnapsToDevicePixels="false"
                   Visibility="{Binding RelativeSource={RelativeSource AncestorType={x:Type Custom:DataGridRow}},
                            Path=(Validation.HasError),
                   Converter={StaticResource bool2VisibilityConverter}}"
                   Template="{Binding RelativeSource={RelativeSource AncestorType={x:Type Custom:DataGridRow}},
                            Path=ValidationErrorTemplate}" />
                    </StackPanel>
                </Custom:DataGridHeaderBorder>
                <Thumb x:Name="PART_TopHeaderGripper"
           VerticalAlignment="Top" Height="3"
           Style="{StaticResource RowHeaderGripperStyle}"/>
                <Thumb x:Name="PART_BottomHeaderGripper"
           VerticalAlignment="Bottom" Height="3"
           Style="{StaticResource RowHeaderGripperStyle}"/>
            </Grid>

            <ControlTemplate.Triggers>                       
                <Trigger Property="IsMouseOver" Value="True">
                    <Setter Property="Background" Value="{StaticResource RowHeaderIsMouseOverBrush}" />
                </Trigger>
                <Trigger Property="IsRowSelected" Value="True">
                    <Setter Property="Background" Value="{StaticResource RowBackgroundSelectedBrush}" />
                </Trigger>
            </ControlTemplate.Triggers>
        </ControlTemplate>
    </Setter.Value>
</Setter>

EN

回答 1

Stack Overflow用户

发布于 2011-08-04 18:28:32

如果我没记错的话,您需要的是网格视图中类似样式的标题。我假设您需要的是一个网格视图列标题样式。为此,您可以使用现有的xaml,并将x:TypeCustom:DataGridRowHeader之类的类名更改为x:Type GridViewColumnHeader。

将Custom:DataGridHeaderBorder更改为普通边框。就是这样。希望你已经有了你提到的所有其他静态资源,比如RowHeaderGripperStyle。快乐编码:)

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/6874046

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档