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 - Button's Command property

 
 
Old 05-19-2006   #1 (permalink)
LEU


 
 

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 SpecsSystem Spec
Old 05-20-2006   #2 (permalink)
John Melville, MD


 
 

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 SpecsSystem Spec
Old 05-23-2006   #3 (permalink)
LEU


 
 

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 SpecsSystem Spec
 

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
Solved Make a command prompt run a command as soon as it opens? General Discussion
Set Focus To Specific Property In Property Grid .NET General


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