I am using Visual Studio 22 with an UWP Project.
I have tried to create a user Control 'Logo' in my project with an custom dependency Property 'Label'.
But when I try to use this Control on my MainPage.xaml
I get this error message:
The XAML Binary Format (XBF) generator reported syntax error '0x09ca'
XAML of Custom Control:
<UserControl
x:Class="MyApp.UI.Images.Logo"
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"
d:DesignHeight="300"
d:DesignWidth="400"
>
<Grid>
<Image
x:Name="ImageLogo"
/>
</Grid>
</UserControl>
Code behind of user Control:
namespace MyApp.UI.Images
{
public sealed partial class Logo : UserControl
{
public static readonly DependencyProperty LabelProperty = DependencyProperty.Register(
"Label",
typeof(string),
typeof(Logo),
new PropertyMetadata(null)
);
public string Label
{
get
{
return (string)GetValue(LabelProperty);
}
set
{
SetValue(LabelProperty, value);
}
}
public Logo()
{
this.InitializeComponent();
}
}
}
MainPage.xaml
<Page xmlns:my="using:Microsoft.UI.Xaml.Controls"
x:Class="MyApp.Pages.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:UI.Images="using:MyApp.UI.Images"
>
<Grid>
.....
<UI.Images:Logo/>
....
</Grid>
</Page>
I have found the problem:
The namespace xmlns:UI.Images
in the MainPage.xaml was it.
`<Page xmlns:my="using:Microsoft.UI.Xaml.Controls"
x:Class="MyApp.Pages.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:UI.Images="using:MyApp.UI.Images"
>
<Grid>
<UI.Images:Logo/>
</Grid>
After renaming it to xmlns:Logo
it worked