且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

在 XAML 根元素中使用 StaticResource

更新时间:2023-10-01 22:48:28

您实际上可以将任何属性设置为元素和属性,包括像 Window.Left 这样简单的属性.

You can actually set any property as an element as well as an attribute, including ones as simple as Window.Left.

这意味着您可以在声明资源后设置 Left 的值.

This means you can set the value of Left after you declare your resources.

<Window.Resources>
    <app:LeftConverter
        x:Key="LeftConverter" />
</Window.Resources>

<Window.Left>
    <Binding
        Path="UnconvertedLeft"
        Converter="{StaticResource LeftConverter}" />
</Window.Left>