What's the signifigance of the colon in XAML

Posted 01 March 2011 - 04:13 PM

I'm very new to WPF. I'm proficient at C#, yet I'm having trouble making sense of all the xaml stuff. What do colons mean? I just downloaded another new wpf tutorial and this one has seemingly random colons strewn about, and I can't even copy and paste the code from that project into another one with out running into an error (Error 1 The tag 'StatusList' does not exist in XML namespace 'clr-namespace:SalesForce'.).

So first off, what does "x:Class=" mean? And what about when we see "x:Name=" or "x:Key" or "xmlns:x" (the x is on the other side, what's going on here?)??

Second, what's the deal with the "my:" prescript? I can't seem to use it in my own solutions, and I can't figure out where to define it correctly. The full source can be downloaded from here if interested.

Replies To: What's the signifigance of the colon in XAML

Re: What's the signifigance of the colon in XAML

Posted 01 March 2011 - 04:17 PM

From what I can gather about XAML, the ':' operand is a lot like using '.' in C#... Don't take my word for it though.

[Edit] It the ':' is prefixing.
At the top of your code you can see xmlns:x, that assigns 'x' to an xml scheme, then using 'x:' allows access to said schema, it's all in here, pay special attention to the "the x: prefix" and "Custom Prefixes and Custom types in XAML" paragraphs.

[Edit2] Further from this, the 'my:' prefix will have been set by assigning xmlns:my="url" at the top of the code.

[Edit3] Further to the above, this line: xmlns:my="http://schemas.microsoft.com/wpf/2008/toolkit"

Re: What's the signifigance of the colon in XAML

Posted 01 March 2011 - 05:39 PM

No problem.

First of all, how are you trying to use it - code and an explanation will be useful so I can see what you're trying to do.
Second of all, make sure you're familiar with the schema you're linking 'my' to.

Re: What's the signifigance of the colon in XAML

Posted 01 March 2011 - 07:27 PM

I fixed it, I needed to add a reference to a dll called WPFToolkit which came with the original project. I'm really just exploring, so I'm not quite sure what I can do with it yet, but when I saw the prefix "my" it made me think that it was somehow creating a new control class the way you can in C# (eg custom controls). But that was just my first hypothesis. After some googling, I'm under the impression that .NET 3.5 must have been lacking stuff like a dataGrid control, and so the WPFToolkit added those missing controls. I'm doing this in 4.0 so I'm thinking I don't need to rely on <my:DataGrid> and can rewrite the tags straight to <DataGrid> as needed without complicating my project with references.

Here's the source I'm describing if you're interested in checking it out. Note that the dll they provided may or may not be authentic, I didn't check it out.

Re: What's the signifigance of the colon in XAML

Posted 02 March 2011 - 08:13 AM

NotarySojac, on 01 March 2011 - 07:27 PM, said:

I fixed it, I needed to add a reference to a dll called WPFToolkit which came with the original project. I'm really just exploring, so I'm not quite sure what I can do with it yet, but when I saw the prefix "my" it made me think that it was somehow creating a new control class the way you can in C# (eg custom controls). But that was just my first hypothesis. After some googling, I'm under the impression that .NET 3.5 must have been lacking stuff like a dataGrid control, and so the WPFToolkit added those missing controls. I'm doing this in 4.0 so I'm thinking I don't need to rely on <my:DataGrid> and can rewrite the tags straight to <DataGrid> as needed without complicating my project with references.

Here's the source I'm describing if you're interested in checking it out. Note that the dll they provided may or may not be authentic, I didn't check it out.

Honestly, you're the first person I've ever tried to help on here that's actually taken a stab at helping themselves along side me. Kudos to you, I'm impressed.
As for custom control classes, no, WPF still works the same way, it all just looks a little different - C# is the language, WPF is the technology, it's essentially just a fancy version of Windows Forms.

When using the WPFToolkit (which I recommend you go up to codeplex and search for, as you may have gotten an older assembly), you should be able to just do <DataGrid>, my recommendation would be to explore both drag & drop + properties window and hard-coded XAML methods of UI construction - good knowledge of both is always good.