绑定到嵌入式类中的静态属性

时间:2018-07-06 12:18:19

标签: c# wpf xaml data-binding

我上课:

public class Class1
{
    public static string Property1
    {
        get
        {
            return "Prop1";
        }
    }

    public class Class2
    {
        public static string Property2
        {
            get
            {
                return "Prop2";
            }
        }
    }
}

XAML:

<ObjectDataProvider x:Key="provider" ObjectType="{x:Type local:Class1}"/>

此作品有效:

<Button Content="{Binding Source={StaticResource provider},Path=Property1}" />

但这不是:

<Button Content="{Binding Source={StaticResource provider},Path=Class2.Property2}" />

如何绑定到Class2.Property2

0 个答案:

没有答案
相关问题