![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #1 (permalink) |
| 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) ); >>>> } >>>> } >>>> >>>> >>> >>> >> >> > > |
![]() |
| 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 |