Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

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.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

"User Control" and Namespaces

Closed Thread
 
Thread Tools Display Modes
Old 02-07-2007   #1 (permalink)
Horst Klein
Guest


 

"User Control" and Namespaces

How can I define a Namespace for User Contols?
Old 02-07-2007   #2 (permalink)
Shawnk
Guest


 

RE: "User Control" and Namespaces

I still a XAML newbie but I think the following is correct.
Is the following what you are looking for?

The format for namespace definition (in a XAML file) is:

[A] xmlns:custom="clr-namespace:SDKSample;assembly=SDKSampleLibrary"

If you have an external assembly of WPF controls
[1] "My_ctr_lib.dll"
with a custom public button type
[2] "My_button"
and wanted to use the XAML namespace prefix
[3] "Ctr_nsp"
to prefix the custom control references.

The XAML namespace defintion is:

[A] xmlns:Ctr_nsp="clr-namespace:My_control_nsp;assembly=My_ctr_lib"

Or:

xmlns:[3]="clr-namespace:[2];assembly=[1]"

Now that the namespace is visible (in XAML code) you can use it with
(1) Object element syntax and (2) Attribute syntax.

To instantiate the control (now that its defined) you

<Ctr_nsp:My_Button Name="My_button_instance">
Button Label
</Ctr_nsp:My_Button>

Note that if your control namespace is IN the same assembly with your
application then you can omit the "assembly=[1]" portion which would yield.

xmlns:[3]="clr-namespace:[2];"

Or:

[A] xmlns:Ctr_nsp="clr-namespace:My_control_nsp;"

If anyone can find a problem with this please let us know :-)

Shawnk

PS. I haven't done this yet but I need to know this.


"Horst Klein" wrote:

> How can I define a Namespace for User Contols?

Old 02-07-2007   #3 (permalink)
Shawnk
Guest


 

RE: "User Control" and Namespaces

As soon as I posted this I noticed an error - the correct answer is:

If you have an external assembly of WPF controls
[1] "My_ctr_lib.dll"
with a CLR (C#,VB,etc) namespace of
[2] "My_control_nsp"
with a custom public button type
[3] "My_button"
and wanted to use the XAML namespace prefix
[4] "Ctr_nsp"
to prefix the custom control references.

The XAML namespace defintion is:

xmlns:Ctr_nsp="clr-namespace:My_control_nsp;assembly=My_ctr_lib"

Or:

xmlns:[4]="clr-namespace:[2];assembly=[1]"

To instantiate the control:

<Ctr_nsp:My_Button Name="My_button_instance">
Button Label
</Ctr_nsp:My_Button>

If your control namespace is IN the same assembly use:

xmlns:[4]="clr-namespace:[2];"

Or:

xmlns:Ctr_nsp="clr-namespace:My_control_nsp;"

Sorry about the mistake in the previous response!

Shawnk



"Shawnk" wrote:

> I still a XAML newbie but I think the following is correct.
> Is the following what you are looking for?
>
> The format for namespace definition (in a XAML file) is:
>
> [A] xmlns:custom="clr-namespace:SDKSample;assembly=SDKSampleLibrary"
>
> If you have an external assembly of WPF controls
> [1] "My_ctr_lib.dll"
> with a custom public button type
> [2] "My_button"
> and wanted to use the XAML namespace prefix
> [3] "Ctr_nsp"
> to prefix the custom control references.
>
> The XAML namespace defintion is:
>
> [A] xmlns:Ctr_nsp="clr-namespace:My_control_nsp;assembly=My_ctr_lib"
>
> Or:
>
> xmlns:[3]="clr-namespace:[2];assembly=[1]"
>
> Now that the namespace is visible (in XAML code) you can use it with
> (1) Object element syntax and (2) Attribute syntax.
>
> To instantiate the control (now that its defined) you
>
> <Ctr_nsp:My_Button Name="My_button_instance">
> Button Label
> </Ctr_nsp:My_Button>
>
> Note that if your control namespace is IN the same assembly with your
> application then you can omit the "assembly=[1]" portion which would yield.
>
> xmlns:[3]="clr-namespace:[2];"
>
> Or:
>
> [A] xmlns:Ctr_nsp="clr-namespace:My_control_nsp;"
>
> If anyone can find a problem with this please let us know :-)
>
> Shawnk
>
> PS. I haven't done this yet but I need to know this.
>
>
> "Horst Klein" wrote:
>
> > How can I define a Namespace for User Contols?

Old 02-07-2007   #4 (permalink)
Horst Klein
Guest


 

Re: "User Control" and Namespaces

Hi Shawnk

Thanks not what I wanna do.
See my Attached Solution

There a two controls:
One Custom Control with NameSpace:
Namespace Controls
Public Class MyCustomControl
Inherits System.Windows.Controls.Grid
End Class
End Namespace
And one UserControl
And how can I keep the UserControl in a NameSpace?

Horst




Old 02-07-2007   #5 (permalink)
Horst Klein
Guest


 

Re: "User Control" and Namespaces

Hi Shawnk

Thanks to explane these basic things.
But in the future the Designtool MS Expression Blend will handle this
declarations.

Best regards
Horst


Old 02-07-2007   #6 (permalink)
Shawnk
Guest


 

Re: "User Control" and Namespaces

Horst,

What language are you using?

"Horst Klein" wrote:

> Hi Shawnk
>
> Thanks not what I wanna do.
> See my Attached Solution
>
> There a two controls:
> One Custom Control with NameSpace:
> Namespace Controls
> Public Class MyCustomControl
> Inherits System.Windows.Controls.Grid
> End Class
> End Namespace
> And one UserControl
> And how can I keep the UserControl in a NameSpace?
>
> Horst
>
>
>

Old 02-07-2007   #7 (permalink)
Horst Klein
Guest


 

Re: "User Control" and Namespaces

Framework 3.0 VB.net


Old 02-08-2007   #8 (permalink)
Patrick Stemmler
Guest


 

Re: "User Control" and Namespaces

On Wed, 7 Feb 2007 16:19:26 +0100, "Horst Klein"
<horst.klein@vitodata.ch> wrote:

>Hi Shawnk
>
>Thanks not what I wanna do.
>See my Attached Solution
>
>There a two controls:
>One Custom Control with NameSpace:
>Namespace Controls
> Public Class MyCustomControl
> Inherits System.Windows.Controls.Grid
> End Class
>End Namespace
>And one UserControl
>And how can I keep the UserControl in a NameSpace?
>
>Horst
>


Old 02-08-2007   #9 (permalink)
Patrick Stemmler
Guest


 

Re: "User Control" and Namespaces

Hi Horst



Try with
<UserControl x:Class="Controls.MyUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
</Grid>
</UserControl>

seems generic.xaml is not matching to the rest of the example so I
commented out this.

I hope this works then
it successfully compiled


see you in coffee room

Patrick





On Wed, 7 Feb 2007 16:19:26 +0100, "Horst Klein"
<horst.klein@vitodata.ch> wrote:

>Hi Shawnk
>
>Thanks not what I wanna do.
>See my Attached Solution
>
>There a two controls:
>One Custom Control with NameSpace:
>Namespace Controls
> Public Class MyCustomControl
> Inherits System.Windows.Controls.Grid
> End Class
>End Namespace
>And one UserControl
>And how can I keep the UserControl in a NameSpace?
>
>Horst
>


Old 02-08-2007   #10 (permalink)
Patrick Stemmler
Guest


 

Re: "User Control" and Namespaces

Hi Horst

try this:

<UserControl x:Class="Controls.MyUserControl"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>

</Grid>
</UserControl>


But i had to comment out the generic.xaml
seems it is not mtaching to the resr of the example....

Hope it works
on my system it compiled


see you in coffee room

Patrick





On Wed, 7 Feb 2007 16:19:26 +0100, "Horst Klein"
<horst.klein@vitodata.ch> wrote:

>Hi Shawnk
>
>Thanks not what I wanna do.
>See my Attached Solution
>
>There a two controls:
>One Custom Control with NameSpace:
>Namespace Controls
> Public Class MyCustomControl
> Inherits System.Windows.Controls.Grid
> End Class
>End Namespace
>And one UserControl
>And how can I keep the UserControl in a NameSpace?
>
>Horst
>


Closed Thread

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Unwanted Multiple contacts in "To","CC","BCC" of email send catago xsailer Vista mail 1 07-26-2008 08:34 AM
Vista not wotking with "My Computer" or "Control Panel", "Screen Saver" Platebanger Vista General 6 02-05-2008 08:54 AM
Vista Upgrade fails at "Gathering Files" when two users share the same user profile (ProfileImagePath). Message: "the upgrade was cancelled". Carl Farrington Vista installation & setup 4 10-24-2007 02:26 AM
WM5 Sync with Vista "Windows Calender", "Contacts", and "Mail" Tony Vista General 1 02-16-2007 06:20 PM
Aero does not fade, but "blinks" during user account control MadsE Vista performance & maintenance 3 06-10-2006 02:45 PM








Vistax64.com 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 2005-2008

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 47 48 49 50