1

我可以将视图直接绑定到我的 Properties.Settings.Default 中的设置吗?或者我需要创建具有相同名称的属性并手动刷新值?

4

1 回答 1

3

尝试这个 :

<Window x:Class="WpfApplication1.MainWindow"
            xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
            xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
            xmlns:Properties="clr-namespace:WpfApplication1.Properties" Title="MainWindow" Height="350" Width="525">
    <Grid>
        <Grid.RowDefinitions>
            <RowDefinition/>
        </Grid.RowDefinitions>

        <Label Content="{Binding Source={x:Static Properties:Settings.Default}, Path=BrandOfBeerOfChoice}"/>

    </Grid>
</Window>

在这个小应用程序中,我创建了一个名为BrandOfBeerOfChoice.

于 2012-10-04T20:11:36.237 回答