我的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" />
问题是我的绑定在调试模式下运行应用程序时似乎可以正常工作,但在发布模式下运行时却无法工作。我不知道该怎么办才能解决此问题,而寻找与此问题相同的其他人让我有些茫然。有人有什么想法吗?