Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Menuitem of a Menu is disabled

$
0
0

Hello. I'm trying to use RoutedCommand and Command in a Menuitem. I have done following:

_commandNewProject = new RoutedCommand("NewProject", typeof(Project));
var binding = new CommandBinding(_commandNewProject, executedEventHandlerDoNewProject, canExecutedEventHandlerDoNewProject);
CommandManager.RegisterClassCommandBinding(typeof(Project), binding);

And Xaml.

<Window x:Class="ListOfActiveEdges.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:my="clr-namespace:ListOfActiveEdges"
        Title="MainWindow" Height="350" Width="525"><DockPanel Name="DockPanel1" VerticalAlignment="Stretch" IsEnabled="True">       <Menu DockPanel.Dock="Top" IsMainMenu="True" Height="Auto" HorizontalAlignment="Left" VerticalAlignment="Top" Width="Auto"><MenuItem Header="_File"><MenuItem Name="New" Header="_New" Command="my:Project.NewProject" CommandTarget="{Binding Source={x:Static my:Project.Instance}}"/></MenuItem></Menu><Grid DockPanel.Dock="Bottom">        <Image Name="ImageContainer"/></Grid></DockPanel>    </Window>

Project.Instance is a static method which returns Project. And Project.Instance is called. But menuitem is inactive all time. Thanks.




Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>