I'm working on a XAML-based app for Windows 10. I'm running into issues when trying to implement a binding in Setters, as per this answer. Here is my code:
namespace Sirloin.Helpers
{
internal class Binding
{
public static readonly DependencyProperty ContentProperty = // ...
public static string GetContent(DependencyObject o) => // ...
public static void SetContent(DependencyObject o, string value) => // ...
}
}
And here is my XAML:
<Page
x:Class="Sirloin.MainPage"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:Sirloin"
xmlns:h="using:Sirloin.Helpers"> <!--Some designer stuff omitted for clarity-->
<Page.Resources>
<ResourceDictionary>
<Style x:Key="MenuButtonStyle" TargetType="Button">
<Setter Property="Background" Value="Transparent"/>
<Setter Property="h:Binding.Content" Value="Symbol"/> <!--The XAML parser chokes on this line-->
<Setter Property="FontFamily" Value="Segoe MDL2 Assets"/>
</Style>
</ResourceDictionary>
</Page.Resources>
</Page>
For some reason, the VS designer seems to be throwing an error when it reaches the lines with the special binding syntax; namely, the one that sets h:Binding.Content
to Symbol
. Here is a screenshot of the message:
Strangely enough, though, the code seems to be compiling fine. When I hit Ctrl + B in Visual Studio, it builds with no errors and successfully outputs the binary. Of course, the drawback to this is I can't use the designer, which claims the XAML to be 'Invalid Markup' every time I build the project.
Can someone recommend me a solution to this problem? I tried the suggestion here of restarting Visual Studio and deleting the cached binaries, but it doesn't seem to be working.
Thanks!