index > Windows Presentation Foundation ("Avalon") > Custom extentions

Custom extentions

Here the code
// XAML of MyWindow.xaml
//1//<Window>
//2//<Menu>
//3//<MenuItem Command="{x:Static custom:MyWindow.SomeRoutedCommand}">
//4//</Menu>
//5//<Window.CommandBindings>
//6//<CommandBinding Command="{x:Static custom:MyWindow.SomeRoutedCommand}" Executed="SomeCommandExecutedHandler" />
//7//</Window.CommandBindings>

//CS of MyWindow.xaml.cs
public partial class MyWindow
{
public static RoutedCommand SomeRoutedCommand= new RoutedCommand();
private void SomeCommandExecutedHandler(Object sender, ExecutedRoutedEventArgs e) {}

All this stuff returns following errors:
Error 1 Unknown build error, 'Key cannot be null. Parameter name: key Line 3 Position 96.'
Error 2 Could not create an instance of type 'StaticExtension'. in line 6

What's wrong? I just want to add my custom routedevent to menuitem without input gestures

Thank you


Tamir Khason

I think you did not add namespace mapping in the XAML window

xmlns:custom="clr-namespace:..."

lee d
I do, but I found other more critical problem. Maybe it's connected. While begun to get thouse errors my editor does not working, but in runtime everything is ok...
This happened after addition of other Window to the project
Tamir Khason
reply 3

You can use google to search for other answers

 

More Articles

• Not able to reference to custom control in another dll (RC1)
• Design question (data binding) -- suggestions?
• Getting Error when try to publish the exe with XML file.
• Dual Monitors .. slow
• Removing (all) items in a databound ListView WPF control
• Show page in new window with WBA
• How does one dispose of IDisposable resources in a Page?
• GroupStyle and WrapPanel
• Using jscript as code-behind with XAML
• XmlNamespaceMapping queries....
Bookmark and Share
Welcome to Bokebb   New Update  
 

New Articles

• Help needed in designing UI using CAB
• Handling Command in Page vs Window
• Web Desktop Windows Security work
• Animations at GDI speed?
• Event for new Window
• Opening .xaml file using ImageBrush in IE
• Displaying popup listview/gridview withi
• Creating a board game
• Unit testing WPF controls with NUnit
• ControlTemplate.Storyboards
• How to put 2 ListBoxItem on same row?
• Ivalidate LayoutTransformation
• Anyway to change WindowsFormsHost z-orde
• Where are the BitmapEffects?
• Subscribing to a PageFunction's Return e

Hot Articles

• SplitButton
• Stretching Frame Content
• Dynamic Gridview columns Update
• How to collapse databound TextBlock
• C# / Object Experts - Why Does this Code
• TextBox wrapping inside a StackPanel...
• WPF + Deskbar Questions
• XAML Namespace Mapping
• How to handle a collection of Words in a
• WPF observable Collection
• Applying styles at runtime
• Get all bindings on a page?
• how to apply Animation to image on click
• What's the distinction between "c:&
• Issue with WPF Designer in Vista Build 5

Recommend Articles

• Missing references in basic WPF example
• Overlapping elements over a FlowDocument
• How can I get textureCoordinate for one
• Problem with DataBinding which has no ef
• NullReferenceException in the samples th
• RC1 Presentation*.dll trouble with VS 2005
• Page.Show() ???
• STA error when creating scrollviewer in
• Animation cpu usage
• Localization
• Feedback please: WPF for LOB application
• Binding to Combobox.Text when IsSynchron
• checkbox capture
• Howto change appearance and/or behavior
• WPF apps slow for some reason