XAML等效代码 [英] XAML equivalent code

查看:70
本文介绍了XAML等效代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我的标签类型的用户控件中有一个属性.
问题是,如果我想从主机应用程序xaml设置此标签的属性值,那么如何实现它.无法找到正确的语法.

Hi,
I have a property in my user control of type Label.
Problem is if I want to set the value of the properties of this label from a host application xaml then how can it be achieved. Not able to find the correct syntax.

public Label TestProperty
        {
            get { return lblValue; }
            set { lblValue = value; }
        }


在后面的代码中,我们可以将该值作为
访问


in the code behind we can access this value as

object.TestProperty.FontSize = 25;


如何从主机应用程序xaml中设置相同的值.


how can I set the same value from the host application xaml.

推荐答案

您应将其实现为 ^ ]
You should implement this as a Dependency Property[^]


我相信以下内容会有所帮助.我相信您需要的是DependencyObject.然后DependencyObject 可以具有DependencyProperties:
http://www.developer.com/net/net/article.php/3648811/Meet-DependencyObject-and-DependencyProperty-the-NET-Data-Binding-Boosters.htm [
I beleive the following will help. What you need I beleive is a DependencyObject. The DependencyObject can then have DependencyProperties:
http://www.developer.com/net/net/article.php/3648811/Meet-DependencyObject-and-DependencyProperty-the-NET-Data-Binding-Boosters.htm[^]
I looked into this before, and could not figure how to solve your problem. I just bypassed the problem by creating specific properties.


这篇关于XAML等效代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆