开发者

XAML binding to another elements command parameter

开发者 https://www.devze.com 2023-03-06 04:15 出处:网络
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 pa

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>


Why can't you simply use the same binding on the buttons CommandParameter e.g:

CommandParameter="{Binding IDForumTopic}" 

..or have I misunderstood your question?

0

精彩评论

暂无评论...
验证码 换一张
取 消