Reputation: 10055
Lets assume my XAML is defined as below with my imported namespace in mycontrols.
<Grid x:Class="LayoutGrid"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
xmlns:mycontrols="clr-namespace:Predefined.Controls;assembly=UIControls"
>
If i was to use something defined in the namespace Predefined.Controls
then i would simply reference it with its alias mycontrols
Example:
<mycontrols:MyCustomButton Name="SubmitButton" />
Now if the namespace Predefined.Controls.CustomTextBoxes
also existed, is there a way to use a control inside this namespace without having to add it to the XAML definition at the top?
Something like this??
<mycontrols.CustomTextBoxes:MyCustomTextBox Name="TextBox1" />
Upvotes: 1
Views: 2627
Reputation: 26213
No. In XML, the namespace prefix defines the namespace, you can't just tack things onto it. You'll need to add the full CLR namespace as an XML namespace declaration in a parent element:
xmlns:ctb="clr-namespace:Predefined.Controls.CustomTextBoxes;assembly=UIControls"
And use that prefix in when you instantiate that element/control in your XAML:
<ctb:MyCustomTextBox />
Upvotes: 2