我有一个带有 XAML 页面的 Visual Studio 2019 UWP 项目,该页面使用依赖属性来绑定值。在调试模式下一切正常,但在发布时却不行。我绑定 VS relase 不喜欢的方式有什么问题?
下面的示例代码显示了一个绑定到 MyDependencyClass DependencyObject 类的 Windows.UI.Xaml.Controls.FontIcon。
<FontIcon FontFamily="{ThemeResource SymbolThemeFontFamily}" Glyph="{Binding ElementName=MyPageUI, Path=(local:myDependencyClass.myGlyph)}" />
错误是 Windows.UI.Xaml.Markup.XamlParseException: 'XAML parsing failed.',这是由于 FontIcon 元素中的此绑定所致。控件的类型无关紧要,同样的错误。
{Binding ElementName=MyPageUI, Path=(local:myDependencyClass.myGlyph)}
public abstract class MyDependencyClass : DependencyObject
{
public static readonly DependencyProperty MyGlyphProperty;
public static void SetMyGlyph(DependencyObject DepObject, string value)
{
DepObject.SetValue(MyGlyphProperty, value);
}
public static string GetMyGlyph(DependencyObject DepObject)
{
return (string)DepObject.GetValue(MyGlyphProperty);
}
static MyDependencyClass()
{
PropertyMetadata MyPropertyMetadata = new PropertyMetadata("\xE72E");
MyGlyphProperty = DependencyProperty.RegisterAttached("MyGlyph",
typeof(string),
typeof(MyDependencyClass),
MyPropertyMetadata);
}