具有直接内容的自定义控件将传递到Commandbar
我有一个自定义控件的想法,但我不知道如何实施它。
假设我有一个控制“ mycontrol”,其中有一个命令栏。
<Control ... MyControl>
<Label Content="Hello" />
<CommandBar>
<DefaultButton Command={Binding DCom1} >
<DefaultButton Command={Binding DCom2} >
<SomePlaceHolderForAdditionalButtons />
</CommandBar>
</Control>
我想执行以下操作:
<MyControl>
<MyAdditionalButton Command={Binding Com1} />
<MyAdditionalButton Command={Binding Com2} />
</MyControl>
之后,MyControl首先加载了两个默认按钮,而两个按钮作为第三个和第四个按钮。
不是 任何帮助都将受到赞赏。
I have an idea for a custom control, but I don't know how to implement it.
Let's say I have a control "MyControl" with a CommandBar in it.
<Control ... MyControl>
<Label Content="Hello" />
<CommandBar>
<DefaultButton Command={Binding DCom1} >
<DefaultButton Command={Binding DCom2} >
<SomePlaceHolderForAdditionalButtons />
</CommandBar>
</Control>
I want to do the following:
<MyControl>
<MyAdditionalButton Command={Binding Com1} />
<MyAdditionalButton Command={Binding Com2} />
</MyControl>
After that, MyControl is loaded with the two default Buttons first and the two provided Buttons as the third and fourth buttons.
Is this even possible? Any help is appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以使模板控制接近。自定义项目属性
ustomcontrol
,然后调用UpdateView
方法将AppBarbutton Element将其推入Default Commandbar。例如
XAML代码
用法
You could make template control to approach. Custom Items property for
CustomControl
, then callUpdateView
method to push AppBarButton element into default commandbar.For example
Xaml Code
Usage