通过添加属性来自定义现有控件
我正在尝试创建一个可以采用标签属性值“Rank”的自定义 AccordionItem:
<local:MyAccItem Header="" Content="" Rank="" />
这实际上不起作用,因为我的控件仅包含一个包含原始 Accordion 项的网格。我尝试操作模板并使用修改后的模板创建了资源文件。但是我想更改我模板化的 AccordionItem 内 Ellipse 对象的大小,以便它根据该项目的排名而变化。我真的被困住了。帮助表示赞赏。
I'm trying to create a custom AccordionItem that can take the tag property value "Rank":
<local:MyAccItem Header="" Content="" Rank="" />
This isn't really working because my control simply contains a grid that contains the original Accordion item. I have tried manipulating the template and have created a Resource file with a modified template. But the I want to change the size of Ellipse object inside the AccordionItem that I have templated so that it changes based on the rank of that item. I'm really getting stuck. Help appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您需要在 MyAccItem UserControl 的代码隐藏中创建一个依赖属性“Rank”。我假设你的排名是一个整数?如果是这样,您可以将其放在后面的代码中,构建,然后它应该在您的 XAML 中工作。
You need to create a Dependency Property 'Rank' in the codebehind of your MyAccItem UserControl. I'm assuming your rank would be an int? If so, you could put this in your code behind, build, then it should work in your XAML.
这些标签用于封装它们之间的代码,因此您可以展开和折叠其中的代码。
这只是为了让事情井井有条,仅此而已!
this tags are used to encapsulate the code between them, so you can expand and collapse the code within them.
it's just to keep things organized, nothing more!