I am working on a universal class library , targeted to use UWP apps.
In this am trying to use Content Dialog to get some user input.
All works good in debug, when I pack my library as dll and distribute, the ContentDialog not showing from the app which refers my dll.
I am getting Windows.UI.Xaml.Markup.XamlParseException: XAML parsing failed exception, i got this through log file.
Here is my code
ContentDialog
<ContentDialog
x:Class="xxxx.yyyy.InputContentDialogue"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
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"
mc:Ignorable="d"
x:Name="dialog"
Title="Title">
<ContentDialog.Resources>
<Style x:Name="ButtonStyleNoTabFocus" TargetType="Button">
<Setter Property="FocusVisualPrimaryBrush" Value="Transparent" />
<Setter Property="Margin" Value="5"/>
</Style>
</ContentDialog.Resources>
<!-- Content body -->
<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}" Margin="0,20" MinWidth="550">
<StackPanel Orientation="Vertical">
<TextBlock TextWrapping="WrapWholeWords" Margin="5,0,0,10">
shkgdsakjfdhgsajkfdhkasd sadkfjahsdkj asdfjasfdja asdkfjasdf asdkjfnas asdkjfnasd
</TextBlock>
<TextBlock Margin="5,0,0,10">sjkdhfkjsdf sdajfakjdsb sadfkajsdfa.
</TextBlock>
<StackPanel Orientation="Horizontal">
<Button TabIndex="0"
HorizontalAlignment="Center"
Content="hey there"
Style="{StaticResource ButtonStyleNoTabFocus}"
x:Name="btn1"
Click="btn1_Click"
GotFocus="Btn_GotFocus"
LostFocus="Btn_LostFocus"/>
<Button HorizontalAlignment="Center"
Content="Hi"
x:Name="btn2"
Style="{StaticResource ButtonStyleNoTabFocus}"
Click="btn2_Click"
GotFocus="Btn_GotFocus"
LostFocus="Btn_LostFocus"/>
<Button HorizontalAlignment="Center"
Content="Hello"
Style="{StaticResource ButtonStyleNoTabFocus}"
x:Name="btn3"
Click="btn3_Click"
GotFocus="Btn_GotFocus"
LostFocus="Btn_LostFocus"/>
</StackPanel>
</StackPanel>
</Grid>
ContentDialog.cs
public sealed partial class InputContentDialogue : ContentDialog
{
public UserConsentContentDialogue()
{
this.InitializeComponent();
this.Result = -1;
this.Closing += ContentDialogue_Closing;
}
private void ContentDialogue_Closing(ContentDialog sender, ContentDialogClosingEventArgs args)
{
if (args.Result == ContentDialogResult.None && this.Result == -1)
{
args.Cancel = true;
}
}
public int Result { get; set; }
// Handle the button clicks from dialog
private void btn1_Click(object sender, RoutedEventArgs e)
{
this.Result = 0;
// Close the dialog
dialog.Hide();
}
private void btn2_Click(object sender, RoutedEventArgs e)
{
this.Result = 1;
// Close the dialog
dialog.Hide();
}
private void btn3_Click(object sender, RoutedEventArgs e)
{
this.Result = 2;
// Close the dialog
dialog.Hide();
}
private void Btn_GotFocus(object sender, RoutedEventArgs e)
{
Brush _blinkBrush = Application.Current.Resources["SystemControlHighlightAccentBrush"] as SolidColorBrush;
(sender as Button).BorderBrush = _blinkBrush;
}
private void Btn_LostFocus(object sender, RoutedEventArgs e)
{
(sender as Button).BorderBrush = new SolidColorBrush(Colors.Transparent);
}
}
And am creating a new instance and try to show the dialog , like this
internal static async Task<int> ShowMyContentDialog()
{
try
{
InputContentDialogue dialogue = new InputContentDialogue();
await dialogue.ShowAsync();
return dialogue.Result;
}
catch(Exception e)
{
FileOperations.WriteToLogFile("ERROR occurred "+ e.ToString());
}
return -1;
}
Everything works good , if I refer this library in code base. If I get release dll and refer it from a test app, am getting the xaml parse exception.
Can anyone help me in this.
Thanks in advance.

Finally, I found the solution.
Thanks @Nico for the answer, its almost answered the question.
Here is the link which gives you the clear picture about the issue
Missing xaml.xr of a class library file in UWP
Steps
1) Check "Generate library layout" in your project properties
2) While copy your dll from bin/release folder, copy these files too
ClassLibrary1(Class Library name) Folder
ClassLibrary1.xr.xml
2.UserControl.xaml (UserControl XAML file)
ClassLibrary1.dll
ClassLibrary1.pri
Keep all these files in the same folder where you keep your library dll.
Just refer your library dll alone to the referrer project.
All other files will be automatically referred .