![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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) |
| | "User Control" and Namespaces How can I define a Namespace for User Contols? |
My System Specs![]() |
| | #2 (permalink) |
| | 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? |
My System Specs![]() |
| | #3 (permalink) |
| | 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? |
My System Specs![]() |
| | #4 (permalink) |
| | 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 |
My System Specs![]() |
| | #5 (permalink) |
| | 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 |
My System Specs![]() |
| | #6 (permalink) |
| | 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 > > > |
My System Specs![]() |
| | #7 (permalink) |
| | Re: "User Control" and Namespaces Framework 3.0 VB.net |
My System Specs![]() |
| | #8 (permalink) |
| | 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 > |
My System Specs![]() |
| | #9 (permalink) |
| | 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 > |
My System Specs![]() |
| | #10 (permalink) |
| | 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 > |
My System Specs![]() |
| Thread Tools | |
| |
Similar Threads | ||||
| Thread | Forum | |||
| Can't access "Network and Sharing Center" nor "User Accounts" | Vista General | |||
Can't access "Network and Sharing Center" nor "User Accounts" | General Discussion | |||
| "User account control - Windows needs your permission to continue" | Vista security | |||
| Vista not wotking with "My Computer" or "Control Panel", "Screen Saver" | Vista General | |||
| Aero does not fade, but "blinks" during user account control | Vista performance & maintenance | |||