Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/xamarin/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Wpf 动态资源访问内部属性_Wpf_Xamarin_Xamarin Forms - Fatal编程技术网

Wpf 动态资源访问内部属性

Wpf 动态资源访问内部属性,wpf,xamarin,xamarin-forms,Wpf,Xamarin,Xamarin Forms,我有以下动态资源: public class Foo { public string bar { get; set; } } 我使用以下方法设置资源: Application.Current.Resources["Foo"] = myFoo; 但当我尝试访问我的酒吧属性时,它不起作用: <Image Source="{DynamicResource Foo.bar}" /> 但是,使用这种方法是可行的: <Image BindingContext="{Dyn

我有以下动态资源:

public class Foo
{
     public string bar { get; set; }
}
我使用以下方法设置资源:

Application.Current.Resources["Foo"] = myFoo;
但当我尝试访问我的酒吧属性时,它不起作用:

<Image Source="{DynamicResource Foo.bar}" />

但是,使用这种方法是可行的:

<Image BindingContext="{DynamicResource Foo}" Source="{Binding bar}" />


问题是,当我不能覆盖我的绑定时,上面的方法不能使用。我的问题是,如何在不重写BindingContext的情况下访问DynamicSource的内部属性?

如果Foo是静态的,那么可以使用:{x:static local:Foo.Bar}