- XaeroDegreaz
- Posts: 29
- Joined:
Unity - When inserting a UserControl inside another XAML, Unity can't find the XAML file
I have a XAML file that embeds another UserControl. If I load the embedded UserControl's XAML in the NoesisView, it loads properly. When I use the control in another XAML, Unity states that it can't find the XAML file. The strange thing is the thumbnail for the "StartScreen" shows the embedded "OptionScreen" when I go to select it and attach the StartScreen to the NoesisView.
Code: Select all
Exception: Xaml not found 'Assets/Ui/OptionScreen.xaml'
NoesisXaml.Load () (at Assets/NoesisGUI/Plugins/NoesisXaml.cs:26)
NoesisView.LoadXaml (Boolean force) (at Assets/NoesisGUI/Plugins/NoesisView.cs:311)
NoesisView.OnEnable () (at Assets/NoesisGUI/Plugins/NoesisView.cs:370)
Code: Select all
namespace KazBall.Ui
{
public partial class OptionScreen : UserControl
{
public OptionScreen()
{
Initialized += (sender, args) =>
{
DataContext = new OptionScreenViewModel();
};
InitializeComponent();
}
private void InitializeComponent()
{
Noesis.GUI.LoadComponent(this, "Assets/Ui/OptionScreen.xaml");
}
}
}
Code: Select all
<UserControl
x:Class="KazBall.Ui.OptionScreen"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:KazBall.Ui"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300">
<TabControl x:Name="tabControl" HorizontalAlignment="Left" Height="100" Margin="89,107,0,0" VerticalAlignment="Top" Width="100">
<TabItem Header="TabItem">
<Grid Background="#FFE5E5E5"/>
</TabItem>
<TabItem Header="TabItem">
<Grid Background="#FFE5E5E5" Margin="-47,-67,-18,5"/>
</TabItem>
</TabControl>
</UserControl>
Code: Select all
<StackPanel
x:Class="KazBall.Ui.StartScreen"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="clr-namespace:KazBall.Ui"
Orientation="Horizontal"<StackPanel
x:Class="KazBall.Ui.StartScreen"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:ui="clr-namespace:KazBall.Ui"
Orientation="Horizontal"
HorizontalAlignment="Center"
VerticalAlignment="Bottom"
Margin="0,0,0,20">
<ui:OptionScreen />
<Button x:Name="button" Content="Button" Width="75"/>
</StackPanel>
Re: Unity - When inserting a UserControl inside another XAML, Unity can't find the XAML file
Hi!
Yes, this is explained in the Unity Tutorial. You need to add the XAMLs you are not directly referencing in a monobehaviour to the preload list you can find in Noesis Settings.
We want to improve this by properly supporting Unity prefabs. Maybe we are already compatible but we didn't test yet...
Yes, this is explained in the Unity Tutorial. You need to add the XAMLs you are not directly referencing in a monobehaviour to the preload list you can find in Noesis Settings.
We want to improve this by properly supporting Unity prefabs. Maybe we are already compatible but we didn't test yet...
Who is online
Users browsing this forum: Ahrefs [Bot], Google [Bot] and 91 guests