I'm trying to add a reference to an external assembly inside XAML
the syntax is the following:
xmlns:my_namespace="using:CompanyName.AssemblyName"
The problem is that the actual class I'd like to use resides under CompanyName.AssemblyName.InnerName namespace.
What's the appropriate way?
Try:
xmlns:my="using:CompanyName.AssemblyName.InnerName"
Related
How can I use the ResourceDictionary resource from the same DLL?
Basically I am trying to create a UI library with all classes derived from Page class. I want to keep all user interface pages in the same DLL.
To see the problem, from VS2012, create a Windows 8 library project, then add the Item Detailed Page. Now, if you open the created page from the editor, you will get some errors like "The resource "LayoutRootStyle" could not be resolved".
This is just a Xaml Designer error, so that will not prevent your project from building or running .
The only thing needed is that all the ResourceDictonary need to be referenced by the main application App.xaml (for example by using <ResourceDictionary Source="/<myLibraryName>/Common/StandardStyles.xaml"/> or by creating calling an Init method in the Library which will dynamically add the Resource dictionary).
A quick workaround for the error in the Xaml Designer is to just copy an App.xaml/App.xaml.cs in your library (but at runtime the main application will still need to have a reference on the needed ResourceDictionary since the App.xaml of the library will not be used).
Another posibility is to just add a refrence on the ResourceDictionary on each page but I believe that will be much more costly since it will create an instance of the dictionary for each page.
in the above deign there is an issue where in i need to add the reference to the (1)DLL in my sample application to get the usercontrol , is there a way to embed the dll(1) inside dll(2) so that i need to only add reference to the DLl2 in my application
If you create a component DLL project (DLL2) and reference DLL1, it will be copied into a project that references this WinRT component without having to explictly reference DLL1.
Is that what you want to achieve?
There is not [XmlnsDefinition] attribute in XAML metro style applications, based on WinRT.
How my custom namespace mappings from WPF/SL apps should be migrated to WinRT XAML apps?
Looks like XmlnsDefinitionAttribute is missing. There is XmlnsDefinition struct but that is of not much use since there is no way to use it to set custom namespace mappings.
A discussion at https://social.msdn.microsoft.com/Forums/windowsapps/en-US/026baea0-6324-46ee-956a-72dbb4c90ca1/xmlnsdefinition-replacement-in-winrt?prof=required says:
there is no analogous attribute.
You might be able to provide similar data in a custom
IXamlMetadataProvider implementation, but since that is automatically
generated for you I'm not sure it can be overridden.
If I have a UserControl: Foo.Bar.MyClass, I know I can reference it in XAML by declaring:
xmlns:foobar="clr-namespace:Foo.Bar"
and then using the reference
<foobar:MyClass />
But if I declare only the Foo namespace:
xmlns:foo="clr-namespace:Foo"
is there a way for me to reference MyClass as Foo:Bar.MyClass in my XAML?
As per my knowledge this is not possible.
You must add assembly reference for the type is being used in XAML.
Similarly it is not possible with C#. You are not able to access type which assembly reference is not included in using list.
I have scenario where my loose xaml file can contain the custom control from another assembly. How do i make a reference to that assembly. My Loose XAML and assembly are at the same path.
I know the embedded xaml or xaml with in a project, the reference is added like this:
xmlns:WpfToolKit="http://schemas.microsoft.com/wpf/2008/toolkit"
Now how can i give similar type of reference in the loose xaml file.
Like so:
xmlns:Awesome="clr-namespace:MyAwesomeNameSpace"
And then use your controls as such:
<Awesome:MyAwesomeControl />
For nice looking schemas, please read this article on MSDN:
http://msdn.microsoft.com/en-us/library/ms747086.aspx
You will need the XmlnsDefinitionAttribute definition on your class.
Hope this helps!