WPF How to acces and edit the MenuItems of a Menu?


  • Hello!

    I am currently switching my Windows Forms project to WPF and am encountering several issues, one of which is the fact that I can't seem to manage accessing the MenuItems of a menu I have programmatically. I mean, all that I can acces through [menuName].Items[index] is the header, but I want to add events and even trigger a renderTransformation. Casting that code to MenuItem simply returns an error stating that "System.String" cannot be converted to MenuItem...

    Is there at least a way to do something like this?

    Thank you!


    This is tha XAML part:

    <Menu Height="40" HorizontalAlignment="Left" Margin="50,80,0,0" Name="days_menu" VerticalAlignment="Top" Width="390" VerticalContentAlignment="Center" HorizontalContentAlignment="Center" FontWeight="Bold" Background="{x:Null}">
             <RotateTransform CenterX="0" CenterY="0" Angle="90">

    Through the days_menu.Items.Add(STRING) method I add the menu Items. That is all that I have by now.

    • Edited by Antonius74 Wednesday, February 29, 2012 4:15 PM Request
    Wednesday, February 29, 2012 2:54 PM


All replies