我有一个包含 DocumentViewer 控件的视图,并且我有另一个类,该类具有公开 FixedDocumentSequence 并实现 INotifyPropertyChanged 的属性。我正在尝试将 documentviewer 的文档属性数据绑定到 FixedDocumentSequence 属性,当我运行它时,documentviewer 不会加载 FixedDocumentSequence。视图中的所有其他绑定都在工作,但不是这个。
以下是任何帮助的代码片段,希望这是我忘记的一些微不足道的事情。
public class Generator : INotifyPropertyChanged
{
private const string _fixedDocumentSequencePropertyName = "Fixed Document Sequence";
private FixedDocumentSequence _fixedDocumentSequence;
public FixedDocumentSequence FixedDocumentSeq
{
get { return _fixedDocumentSequence; }
private set
{
this._fixedDocumentSequence = value;
onPropertyChanged(_fixedDocumentSequencePropertyName);
}
}
#region INotifyPropertyChanged Members
public event PropertyChangedEventHandler PropertyChanged;
private void onPropertyChanged(string propertyName)
{
if (this.PropertyChanged != null)
{
this.PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
#endregion
}
这是相关的xaml:
<Window.Resources>
<ResourceDictionary>
<generator:Generator x:Key="gen"/>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Resources/StyleDictionary.xaml"/>
<ResourceDictionary Source="Resources/AnimationDictionary.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Window.Resources>
<Grid DockPanel.Dock="Top"
Margin="0,0,0,20" DataContext="{Binding Source={StaticResource gen}}">
<DocumentViewer Name="documentViewer1" Margin="6,180,8,0" Visibility="Visible" Document="{Binding Path=FixedDocumentSeq, Mode=OneWay}"/>
</Grid>