Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

Re: Mapping custom command to MenuItem

Closed Thread
 
Thread Tools Display Modes
Old 01-10-2006   #1 (permalink)
Ryan Milligan
Guest


 

Re: Mapping custom command to MenuItem

It's not finding your command because the XmlNamespace attribute in your
Mapping directive says "local" but you've set xmlns:local="urn:local". Make
them the same and it should work. Hope this helps!

-- Ryan Milligan

"Paul van Brenk" <paul.van.brenk@nospam.tamtam.nl> wrote in message
news:eRL4uM28FHA.476@TK2MSFTNGP15.phx.gbl...
> Nope, that didn't help either... I'll stick to the code behind for now.
>
> I thought the Initialize method call in the constructor would initialize
> all the 'controls' in the xaml. apperently it does not... I ended up
> overriding the EnInit method and hooking up the events there.
>
> Paul
>
> "Michael Latta" <lattam@mac.com> wrote in message
> news:OY8XCdu8FHA.3804@TK2MSFTNGP14.phx.gbl...
>>I use the following to define a command I use in the same way you are
>>(qualified class.command):
>> public static readonly RoutedUICommand Finish = new RoutedUICommand(
>>
>> "Finish", "Finish", typeof(Wizard));
>>
>> But, my references to the command are in another assembly so I need to
>> have the assembly name in the mapping directive. I have found several
>> cases where I can not reference things in the same assembly as they are
>> defined in. This most likely is because it is looking at some output
>> artifact to validate the XAML which has not been built yet if they are in
>> the same assembly. It may also be that you need to make your command
>> public.
>>
>> Fields named in the XAML file are not usable until you receive the Loaded
>> event from the window.
>>
>> Michael
>>
>>
>>
>>
>> "Paul van Brenk" <paul.van.brenk@nospam.tamtam.nl> wrote in message
>> news:e80Hayt8FHA.808@TK2MSFTNGP09.phx.gbl...
>>> btw: I'm running the november CTP
>>>
>>> And I noticed something else; in the constructor of my window all the
>>> controls on the form are null. When are those initialized, i.e. when can
>>> I access their properties in the cs file?
>>>
>>> Paul
>>>
>>>
>>> "Paul van Brenk" <paul.van.brenk@nospam.tamtam.nl> wrote in message
>>> news:OefX4gt8FHA.736@TK2MSFTNGP09.phx.gbl...
>>>>I have declare a field in my xaml.cs file, which is a RouterCommand and
>>>>want to invoke that command when I select a menuitem. But the parser
>>>>keeps thinking I'm trying to load a string in Command Property.
>>>>
>>>> The xaml:
>>>>
>>>> <?Mapping ClrNamespace="memory" XmlNamespace="local"?>
>>>> <Window x:Class="memory.MainWindow"
>>>> xmlns:local="urn:local"
>>>>
>>>> xmlns="http://schemas.microsoft.com/winfx/avalon/2005"
>>>> xmlns:x="http://schemas.microsoft.com/winfx/xaml/2005"
>>>> Title=".Net Books memory"
>>>> >
>>>> <DockPanel LastChildFill="True">
>>>> <!-- start menu -->
>>>> <Menu DockPanel.Dock="Top">
>>>> <MenuItem Header="_File">
>>>> <MenuItem Header="_New" Command="New" />
>>>> <Separator />
>>>> <MenuItem Header="E_xit" Command="Close"/>
>>>> </MenuItem>
>>>> <MenuItem Header="_Help">
>>>> <MenuItem Header="_About" Command="local:MainWindow.About"/>
>>>> </MenuItem>
>>>> </Menu>
>>>> <!-- end menu -->
>>>> </DockPanel>
>>>> </Window>
>>>>
>>>> The xaml.cs
>>>>
>>>> namespace memory {
>>>> /// <summary>
>>>> /// Interaction logic for Window1.xaml
>>>> /// </summary>
>>>>
>>>> public partial class MainWindow : Window {
>>>>
>>>> // constructor
>>>> public MainWindow() {
>>>> InitializeComponent();
>>>>
>>>>
>>>> }
>>>>
>>>>
>>>> static RoutedCommand About= new RoutedCommand("About",
>>>> typeof(MainWindow) );
>>>> }
>>>> }
>>>>
>>>>
>>>
>>>

>>
>>

>
>



Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Define Menu and MenuItem in Xml file knallkopf66 Avalon 0 07-17-2007 07:51 AM
handling command in menuitem viRtual Avalon 0 08-08-2006 02:39 AM
Using Custom Command in EID viRtual Avalon 0 08-01-2006 03:13 AM
Binding to custom command in InputBindings Johann MacDonagh Avalon 4 04-25-2006 10:59 AM
Custom Dependency Property in custom class hierarchy not workingcorrectly?! MueMeister Avalon 0 03-02-2006 06:19 PM








Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50