0

我正在动态加载一个 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。

4

1 回答 1

1

你可以FontSize在你的xaml中更改。

<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
}
于 2013-02-28T21:58:33.660 回答