问题描述
我有一个包含DocumentViewer控件的视图,我有另一个类具有暴露一个FixedDocumentSequence并实现INotifyPropertyChanged的属性。我试图将文档查看器的文档属性数据绑定到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成员
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,20DataContext ={Binding Source = {StaticResource gen}}>
< DocumentViewer Name =documentViewer1Margin =6,180,8,0Visibility =VisibleDocument ={Binding Path = FixedDocumentSeq,Mode = OneWay}/>
< / Grid>
尝试返回IDocumentPaginatorSource。您应该可以将_fixedDocumentSequence转换为IDocumentPaginatorSource。
I have a view that contains a DocumentViewer control and I have another class that has a property that exposes a FixedDocumentSequence and implements INotifyPropertyChanged. I am trying to databind the document property of the documentviewer to the FixedDocumentSequence property, when I run it the documentviewer does not load the FixedDocumentSequence. All ofthe other bindings in the view are working but not this one.
Here are the code snippets any help would be appreciated, hopefully it is something trivial that I am forgeting.
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
}
and here is the relevant 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>
Is the get called? Try returning IDocumentPaginatorSource. You should be able to cast the _fixedDocumentSequence to IDocumentPaginatorSource.
这篇关于数据绑定到DocumentViewer.Document属性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!