XAML 绑定到另一个元素命令参数
我有一个包含项目的列表框 - 每个项目都包含一个超链接和一个按钮。我正在使用 MVVM 和 Commanding。超链接的命令参数绑定到“IDForumTopic”。我想从按钮传递与超链接传递相同的参数:
<HyperlinkButton x:Name='hlTopicText'
Content='{Binding ForumTopicText}'
FontWeight='Bold'
Margin='5,0,0,0'
Width='175'
Command='{Binding LoadThreadHeadersCommand,Source={StaticResource ViewModel}}'
CommandParameter='{Binding IDForumTopic}'>
</HyperlinkButton>
<Button Content='New Post'
Background='Orange'
Command='{Binding NewForumPostWindowCommand,Source={StaticResource ViewModel}}'
CommandParameter='{???}'>
</Button>
I have a ListBox with Items - Each item consists of a Hyperlink and a Button. I am using MVVM and Commanding. The hyperlink's commandparameter is bound to "IDForumTopic". I want to pass the same parameter from the button as the hyperlink is passing:
<HyperlinkButton x:Name='hlTopicText'
Content='{Binding ForumTopicText}'
FontWeight='Bold'
Margin='5,0,0,0'
Width='175'
Command='{Binding LoadThreadHeadersCommand,Source={StaticResource ViewModel}}'
CommandParameter='{Binding IDForumTopic}'>
</HyperlinkButton>
<Button Content='New Post'
Background='Orange'
Command='{Binding NewForumPostWindowCommand,Source={StaticResource ViewModel}}'
CommandParameter='{???}'>
</Button>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
为什么你不能简单地在按钮 CommandParameter 上使用相同的绑定,例如:
..或者我误解了你的问题?
Why can't you simply use the same binding on the buttons CommandParameter e.g:
..or have I misunderstood your question?