将函数更改为依赖属性
我是 XAML 和 WPF 的新手,正在学习 DependencyProperty 和 Path。例如,我有一个这样的函数
public byte[] DownloadPicture()
{
WebClient webClient = new WebClient();
byte[] data;
data = webClient.DownloadData("https://graph.facebook.com/4/picture&type=large");
return data;
}
,并且我有这样的 dependencyproperty
public static DependencyProperty DownloadPicProperty =
DependencyProperty.Register("DownloadPic", typeof(byte),
typeof(ImageControl), new PropertyMetadata(false));
如何将 DependencyProperty 与我编写的 DownloadPicture 函数连接起来?有什么建议吗?我应该在 CLR 包装器中写什么?
I am new to XAML and WPF and I am learning about DependencyProperty and Path. For example, I have a function like this
public byte[] DownloadPicture()
{
WebClient webClient = new WebClient();
byte[] data;
data = webClient.DownloadData("https://graph.facebook.com/4/picture&type=large");
return data;
}
and I have dependencyproperty like this
public static DependencyProperty DownloadPicProperty =
DependencyProperty.Register("DownloadPic", typeof(byte),
typeof(ImageControl), new PropertyMetadata(false));
How can I connect the DependencyProperty with the DownloadPicture function I wrote? Any suggestions? What should I write in the CLR wrapper?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您还可以通过向控件添加标准属性来获取和设置依赖项属性的值。
You can get and set the value of a dependency property by adding a standard property to the control as well.