I'm trying to get multiple Xaml files to work with my application to get my app code organized. I've tried multiple would-be solutions to no avail. I've tried a couple of XamlReader solutions I couldn't get working. Here are some of the things I've tried:
Simple Xaml code:
Simple solution provided by experts on StackOverflow:
I would prefer a simpler approach such as the following:
Does anyone have any ideas on how to get this working? Thanks in advance.
Simple Xaml code:
Code:
<Grid RowDefinitions="Auto,*">
<Button
Grid.Row="0"
Click="LoadXamlButton_Click"
Content="Load XAML" />
<Frame
x:Name="DynamicFrame"
Grid.Row="2" />
</Grid>
Simple solution provided by experts on StackOverflow:
Code:
private async void LoadXamlButton_Click(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
string loadedXamlText = await File.ReadAllTextAsync("AuxFile.xaml");
if (Microsoft.UI.Xaml.Markup.XamlReader.Load(loadedXamlText) is FrameworkElement dynamicElement)
{
this.DynamicFrame.Content = dynamicElement;
}
}
I would prefer a simpler approach such as the following:
Code:
<Page x:Name="AuxFile" Resources="AuxFile.xaml"></Page>
Does anyone have any ideas on how to get this working? Thanks in advance.