![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
|
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.
br> br> |
| |||||||
![]() |
| | Thread Tools | Display Modes |
| | #2 (permalink) |
| 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? |
| | #3 (permalink) |
| 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? |
| | #4 (permalink) |
| 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 |
| | #6 (permalink) |
| 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 > > > |
| | #8 (permalink) |
| 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 > |
| | #9 (permalink) |
| 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 > |
| | #10 (permalink) |
| 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 > |
| |
| |
![]() |
| 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 |