Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - Re: Mapping custom command to MenuItem

 
 
Old 01-10-2006   #1 (permalink)
Ryan Milligan


 
 

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) );
>>>> }
>>>> }
>>>>
>>>>
>>>
>>>

>>
>>

>
>




My System SpecsSystem Spec
 

Thread Tools



Vista Forums 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 Ltd

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