资源字典文件背后的代码 [英] Code behind file for Resource Dictionary

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

问题描述

大家好,

我有一个问题,就我看来,没有找到解决方法!
我有一个带有2个控制模板的xaml资源字典:模板1"和"Template2".
"Template1"由一个矩形和一个标签组成.
在主应用程序窗口中,用户可以将此控件模板的副本拖到画布上,然后将其拖放到所需的位置(例如图表设计器).我想要的是用户能够更改"Template1"标签的内容.
我试图添加一个依赖项,如下所示:

<

hello all,

I have a question and as far as I looked ,I didnt find sth to solve it!
I have an xaml resource dictionary with 2 control templates: "Template1" and "Template2".
"Template1" consists of a rectangle and a label.
In the main application window ,the user can drag copies of this control templates over a canvas and drop them wherever he wants (like a diagram designer).What I want is the user to be able to change the content of the label of the "Template1".
I tried to add a dependency project like this:

<

标签 名称 ="label1" 内容 =&"; { 绑定 = Template1, 路径 = Message}" ></ 标签 >

Label Name="label1" Content="{Binding ElementName=Template1, Path=Message}" ></Label>

公开

静态 MessageProperty = DependencyProperty 消息" ( 字符串 (Template1

static DependencyProperty MessageProperty = DependencyProperty.Register("Message", typeof(string), typeof(Template1));

 

公共 消息

获取

{

返回 ( )GetValue(MessageProperty);

设置

{

SetValue(MessageProperty,

SetValue(MessageProperty,

);

}

}


不幸的是,它告诉我GetValue和SetValue不存在...尽管我很确定我已经添加了所有需要的引用!
有人可以吗?请帮我吗?
先谢谢!

}


Unfortunately,it says to me that GetValue and SetValue dont exist... although I m pretty sure I ve added all the references needed!
Can someone plase help me?
Thanx in advance!

}

{

推荐答案

请参见.


这篇关于资源字典文件背后的代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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