我有一个包含DocumentViewer控件的视图,我有另一个具有暴露FixedDocumentSequence并实现INotifyPropertyChanged的属性的类。我试图将documentviewer的document属性数据绑定到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>
答案 0 :(得分:0)
被叫吗?尝试返回IDocumentPaginatorSource。您应该能够将_fixedDocumentSequence转换为IDocumentPaginatorSource。