开发者

How can I change the fontsize of a GridviewColumnHeader?

I included everything below since it's not that much. I wasn't sure if something I put elsewhere was causing my setter to not work properly.

                <ListView x:Name="lvReports"
                             SelectionMode="Single"
                             ItemsSource="{Binding reportsCollection}" Height="432" ScrollViewer.HorizontalScrollBarVisibility="Hidden">
                    <ListView.Resources>
                        <Style x:Key="myHeaderStyle" TargetType="{x:Type GridViewColumnHeader}">
                            <Setter Property="HorizontalContentAlignment" Value="Left"/>
                            <Setter Property="TextElement.FontSize" Value="30pt"/>
                            <Setter Property="Width" Value="800"/>
                        </Style>
                    </ListView.Resources>
                    <ListView.GroupStyle>
                        <GroupStyle>
                            <GroupStyle.HeaderTemplate>
                                <DataTemplate>
                                    <DockPanel>
                                        <DockPanel Height="30" VerticalAlignment="B开发者_C百科ottom">
                                            <Image Source="\Images\ProductivityByEmployeesReport.png"/>
                                            <TextBlock FontWeight="Bold" FontSize="18pt" Text="{Binding Path=Name}"/>
                                        </DockPanel>
                                    </DockPanel>
                                </DataTemplate>
                            </GroupStyle.HeaderTemplate>
                        </GroupStyle>
                    </ListView.GroupStyle>
                    <ListView.View>
                        <GridView>
                            <GridViewColumn x:Name="colName" HeaderContainerStyle="{StaticResource myHeaderStyle}" Header="Reports">
                                <GridViewColumn.CellTemplate>
                                    <DataTemplate>
                                        <DockPanel>
                                            <Rectangle Width="18"/>
                                            <CheckBox>
                                                <TextBlock Text="{Binding displayName}"/>
                                            </CheckBox>
                                        </DockPanel>
                                    </DataTemplate>
                                </GridViewColumn.CellTemplate>
                            </GridViewColumn>
                        </GridView>
                    </ListView.View>
                </ListView>

Thanks in advance.


Add this to <ListView.Resources>

<Style TargetType="GridViewColumnHeader" x:Key="ColumnHeaderLarge">
   <Setter Property="FontSize" Value="14"/>
</Style>

To set Fontsize to 14, use the style as:

<GridView ColumnHeaderContainerStyle="{StaticResource ColumnHeaderLarge}">
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜