![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
| |
| | #1 (permalink) |
| | Button's Command property Hi, Question: What is a proper syntax of the Button's Command property. I have WinFX Runtime Components 3.0 (Beta 2). The code: <?Mapping XmlNamespace="urn:Czajnik" ClrNamespace="CzajnikApp" Assembly="Czajnik" ?> <Window x:Class="CzajnikApp.Czajnik" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:loc="urn:MediaController"> <Button Command="loc:Czajnik.Herbata">Herbata</Button> </Window> generates an error (at runtime): "Error at element 'Button' in markup file 'Czajnik.xaml' : 'loc:Czajnik.Herbata' string is not a valid value for 'Command' property of type 'ICommand'" The code: <?Mapping XmlNamespace="local" ClrNamespace="CzajnikApp" ?> <Window x:Class="CzajnikApp.Czajnik" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:loc="local" > <Button Command="{x:Static loc:Czajnik.Herbata}">Herbata</Button> </Window> generates an error (at runtime): "Type reference cannot find public Type named 'Czajnik'" The code-behind is as follows: namespace CzajnikApp { public partial class Czajnik : Window { public Czajnik() { InitializeComponent(); } private static AppCommand herbata; public static ICommand Herbata { get { if (herbata == null) { herbata = new AppCommand(10); } return herbata; } } } } I have run out of ideas how to make it works. Please share some knowledge if you had a similar problem. Thanks, Leszek |
My System Specs![]() |
| | #2 (permalink) |
| | RE: Button's Command property Which CTP are you using? If you're using the february (currently latest CTP) then your button syntax is right but the mapping PI's you're using to access your local namespace are obsolete. see: http://blogs.msdn.com/karstenj/archi...22/537049.aspx try changing your namespace decl to xmlns:loc="clr-namespace:CzajnikApp" and see if it works better. A lot of uther stuff changed in the feb ctp as well, so read Kardsten's post referenced above. If you're not using the Feb CTP, consider upgrading. I'd hate to do a lot of work debugging an obsolete platform. Cheers JDM "LEU" wrote: > Hi, > > Question: > What is a proper syntax of the Button's Command property. I have WinFX > Runtime Components 3.0 (Beta 2). > > The code: > <?Mapping XmlNamespace="urn:Czajnik" ClrNamespace="CzajnikApp" > Assembly="Czajnik" ?> > <Window x:Class="CzajnikApp.Czajnik" > xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" > xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > xmlns:loc="urn:MediaController"> > <Button Command="loc:Czajnik.Herbata">Herbata</Button> > </Window> > > generates an error (at runtime): > "Error at element 'Button' in markup file 'Czajnik.xaml' : > 'loc:Czajnik.Herbata' string is not a valid value for 'Command' property of > type 'ICommand'" > > The code: > <?Mapping XmlNamespace="local" ClrNamespace="CzajnikApp" ?> > <Window x:Class="CzajnikApp.Czajnik" > xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" > xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > xmlns:loc="local" > > <Button Command="{x:Static loc:Czajnik.Herbata}">Herbata</Button> > </Window> > > generates an error (at runtime): > "Type reference cannot find public Type named 'Czajnik'" > > The code-behind is as follows: > > namespace CzajnikApp > { > public partial class Czajnik : Window > { > public Czajnik() > { > InitializeComponent(); > } > > private static AppCommand herbata; > public static ICommand Herbata > { > get > { > if (herbata == null) > { > herbata = new AppCommand(10); > } > return herbata; > } > } > } > } > > I have run out of ideas how to make it works. > Please share some knowledge if you had a similar problem. > > Thanks, > Leszek > > > |
My System Specs![]() |
| | #3 (permalink) |
| | Re: Button's Command property Thanks John! Yeah, I have missed the change in namespace declaration. Thanks for the link as well. BTW My main source of WPF knowledge is the Chris Sells's book. They updated their code in Errata 3 (for Feb CTP that I'm using). I just skipped it so quickly that I did not notice the change. Now my app works fine. Thanks again, Leszek "John Melville, MD" <JohnMelvilleMD@discussions.microsoft.com> wrote in message news:C60E5B58-C604-42C1-A207-AFB7F9CD9CF5@microsoft.com... > Which CTP are you using? If you're using the february (currently latest > CTP) > then your button syntax is right but the mapping PI's you're using to > access > your local namespace are obsolete. > > see: http://blogs.msdn.com/karstenj/archi...22/537049.aspx > > try changing your namespace decl to > xmlns:loc="clr-namespace:CzajnikApp" > and see if it works better. > > A lot of uther stuff changed in the feb ctp as well, so read Kardsten's > post > referenced above. > > If you're not using the Feb CTP, consider upgrading. I'd hate to do a lot > of work debugging an obsolete platform. > > Cheers > > JDM > > "LEU" wrote: > >> Hi, >> >> Question: >> What is a proper syntax of the Button's Command property. I have WinFX >> Runtime Components 3.0 (Beta 2). >> >> The code: >> <?Mapping XmlNamespace="urn:Czajnik" ClrNamespace="CzajnikApp" >> Assembly="Czajnik" ?> >> <Window x:Class="CzajnikApp.Czajnik" >> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >> xmlns:loc="urn:MediaController"> >> <Button Command="loc:Czajnik.Herbata">Herbata</Button> >> </Window> >> >> generates an error (at runtime): >> "Error at element 'Button' in markup file 'Czajnik.xaml' : >> 'loc:Czajnik.Herbata' string is not a valid value for 'Command' property >> of >> type 'ICommand'" >> >> The code: >> <?Mapping XmlNamespace="local" ClrNamespace="CzajnikApp" ?> >> <Window x:Class="CzajnikApp.Czajnik" >> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" >> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >> xmlns:loc="local" > >> <Button Command="{x:Static loc:Czajnik.Herbata}">Herbata</Button> >> </Window> >> >> generates an error (at runtime): >> "Type reference cannot find public Type named 'Czajnik'" >> >> The code-behind is as follows: >> >> namespace CzajnikApp >> { >> public partial class Czajnik : Window >> { >> public Czajnik() >> { >> InitializeComponent(); >> } >> >> private static AppCommand herbata; >> public static ICommand Herbata >> { >> get >> { >> if (herbata == null) >> { >> herbata = new AppCommand(10); >> } >> return herbata; >> } >> } >> } >> } >> >> I have run out of ideas how to make it works. >> Please share some knowledge if you had a similar problem. >> >> Thanks, >> Leszek >> >> >> |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Running a command from inside a script, command line is corrupted | PowerShell | |||
| What is the command line command for unzipping files? | Vista General | |||
Make a command prompt run a command as soon as it opens? | General Discussion | |||
| Set Focus To Specific Property In Property Grid | .NET General | |||