如何在gridview中增加文本大小

时间:2013-02-28 21:25:47

标签: c# wpf gridview

我正在动态加载xaml文件。这就是xaml的样子:

<ListView  Grid.Row="2" BorderBrush="White"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Name="ListView1"
    ItemsSource="{Binding Path=line}"
    HorizontalAlignment="Stretch">

    <ListView.View>
        <GridView>
            <GridViewColumn Header="Lines"
                DisplayMemberBinding="{Binding Path=aline}" />
        </GridView>
    </ListView.View>
</ListView >

无法更改xaml。

1 个答案:

答案 0 :(得分:1)

您只需更改xaml中的FontSize

<ListView  Grid.Row="2" BorderBrush="White" FontSize="20" .................

但是,如果您从文件加载Xaml,则必须先加载它然后更改FontSize

示例:

using (FileStream stream = new FileStream("c:\\test.xaml", FileMode.Open))
{
    var listView = (ListView)XamlReader.Load(stream);

    // change font size
    listView.FontSize = 20;

    // apply listView to whatever you need
}