I'm trying to build the example project that is provided in the Avalonia website but I'm having difficulty with certain parts.
I want to use a xaml element in a xaml window in another file like so:
<Window xmlns="https://github.com/avaloniaui"
xmlns:local="using:Buguette.Views">
<Panel>
<local:MusicStoreView />
</Panel>
</Window>
But I'm getting an error saying "Unable to resolve type MusicStoreView from namespace using:Buguette.Views". (MusicStoreView is the name of the file I'm trying to include here).
However everything works fine when I just copy the contents of the MusicStoreView file to where <local:MusicStoreView /> is supposed to be.
I followed the steps in the website but I'm still getting this error.
Any help would be much appreciated.
You need to use clr-namespace:
<Window xmlns="https://github.com/avaloniaui"
xmlns:local="clr-namespace:Buguette.Views">
<Panel>
<local:MusicStoreView />
</Panel>
</Window>
Sometimes you also need to provide the assembly name, such as:
xmlns:viewModels="clr-namespace:MyApp.Core.ViewModels;assembly=Myapp.Core"
Thanks to Jammer.
I had to set the UserControl to:
<UserControl xmlns="https://github.com/avaloniaui"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:views="clr-namespac/e:ToDoList.Views"
mc:Ignorable="d" d:DesignWidth="250" d:DesignHeight="450"
x:Class="ToDoList.Views.ToDoListView">
Suca dio cane
</UserControl>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With