开发者

WPF - Is it possible to create this binding?

开发者 https://www.devze.com 2023-01-28 22:38 出处:网络
Hi I would like create this binding. I have menu, something like this. <Menu IsMainMenu=\"True\" Grid.Column=\"0\" Grid.Row=\"0\">

Hi I would like create this binding. I have menu, something like this.

<Menu IsMainMenu="True" Grid.Column="0" Grid.Row="0">
   <开发者_JAVA技巧;MenuItem Header="_MyMenu">
      <MenuItem Header="_Status">
         <MenuItem Name="Online" Header="Online" Click="StatusMenuItem_Click">
            <MenuItem.Icon>
               <Image Source="images\icons\menu\online.ico" Height="20"/>
            </MenuItem.Icon>
         </MenuItem>
      </MenuItem>
   </MenuItem>
</Menu>

I would like create binding with menu item Name to string property of object, and as UpdateSourceTriger I would like have a event click on menu item.


You can easily solve this using a framework like Caliburn.Micro!


What's the point in updating source? MenuItems do not provide any way to let user modify their Header. So even if you force Binding to update source your object will receive the same value it already contains. If you wish to notify the object that it's corresponding MenuItem was clicked you'd better use Commands (the article describes Silverlight, but it's true for WPF too)

0

精彩评论

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

关注公众号