0

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>
4

1 に答える 1

0

getは呼び出されますか?IDocumentPaginatorSourceを返してみてください。_fixedDocumentSequenceをIDocumentPaginatorSourceにキャストできるはずです。

于 2011-12-20T20:42:51.940 に答える