Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/visual-studio/7.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
C# 如何将后台属性绑定到代码中的WriteableBitmap?_C#_Xaml_Windows Phone 8_Data Binding - Fatal编程技术网

C# 如何将后台属性绑定到代码中的WriteableBitmap?

C# 如何将后台属性绑定到代码中的WriteableBitmap?,c#,xaml,windows-phone-8,data-binding,C#,Xaml,Windows Phone 8,Data Binding,我试图在代码中将Border元素的Background属性绑定到WriteableBitmap类型的属性 作为WriteableBitmap的图像,我尝试了以下操作,但没有成功,因此,边框显示时没有任何背景: Binding b = new Binding(); b.Source = dataContext.Image; myBorder.SetBinding(Border.BackgroundProperty, b); dataContext.Image = new WriteableBit

我试图在代码中将Border元素的Background属性绑定到WriteableBitmap类型的属性

作为WriteableBitmap的图像,我尝试了以下操作,但没有成功,因此,边框显示时没有任何背景:

Binding b = new Binding();
b.Source = dataContext.Image;
myBorder.SetBinding(Border.BackgroundProperty, b);

dataContext.Image = new WriteableBitmap(1, 1);
dataContext.Image.SetSource(e.ChosenPhoto);

我遗漏了什么?

我不确定
Image
是否是您的财产,但您可以这样尝试:

Binding b = new Binding();
b.Path = new PropertyPath("Image"); // Image should be a public property in your datacontext
b.Source = dataContext;
myBorder.SetBinding(Border.BackgroundProperty, b);

dataContext.Image = new WriteableBitmap(1, 1);
dataContext.Image.SetSource(e.ChosenPhoto);
RaiseProperty("Image"); //raise property change