首页 > 解决方案 > 仅在发行版中存在 UWP 绑定问题

问题描述

我的 UWP 应用程序中的数据绑定存在问题。我有一个有属性的类。

Public Class Settings
    Implements INotifyPropertyChanged

    Private _EditorFont As String
    Private _IsDirty As Boolean = False

    Public Event PropertyChanged As PropertyChangedEventHandler Implements INotifyPropertyChanged.PropertyChanged
    Public Event Dirtied As EventHandler

    Public Property EditorFont As String
            Get
                Return _EditorFont
            End Get
            Set(value As String)
                If value <> _EditorFont Then
                    _EditorFont = value
                    RaisePropertyChanged(NameOf(EditorFont))
                    MakeDirty()
                End If
            End Set
    End Property

    Protected Sub RaisePropertyChanged(ByVal Name As String)
            RaiseEvent PropertyChanged(Me, New PropertyChangedEventArgs(Name))
    End Sub

    Protected Overridable Sub OnDirtied(ByVal e As EventArgs) Implements ISaveable.OnDirtied
            RaiseEvent Dirtied(Me, e)
    End Sub

    Public Sub MakeDirty()
            If IsDirty = False Then
                IsDirty = True
                OnDirtied(EventArgs.Empty)
            End If
    End Sub
End Class

我还有一个 RichEditBox 控件,它将字体系列绑定到我的类的属性:

<RichEditBox Grid.Column="1" Grid.Row="0" AcceptsReturn="True" Padding="5,10,5,5" x:Name="Editor"
             TextChanged="Editor_TextChanged" FontFamily="{x:Bind Settings.EditorFont, Mode=OneWay}"
             SelectionChanged="Editor_SelectionChanged"
             Loaded="Editor_Loaded" PreviewKeyDown="TextBox_KeyDown" />

问题是我的绑定在调试模式下运行应用程序时似乎工作正常,但在发布模式下运行时无法工作。我不知道该怎么做才能解决这个问题,而且在找到其他有同样问题的人方面我有点茫然。有人有想法吗?

标签: c#vb.netdata-bindinguwp

解决方案


推荐阅读