Привязка данных к свойству DocumentViewer.Document - PullRequest
0 голосов
/ 20 декабря 2011

У меня есть представление, которое содержит элемент управления DocumentViewer, и у меня есть другой класс, у которого есть свойство, которое предоставляет FixedDocumentSequence и реализует INotifyPropertyChanged. Я пытаюсь связать данные свойства документа в окне просмотра документов со свойством FixedDocumentSequence, когда я запускаю его, просмотрщик документов не загружает 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>

1 Ответ

0 голосов
/ 21 декабря 2011

Вызывается ли? Попробуйте вернуть IDocumentPaginatorSource. Вы должны иметь возможность привести _fixedDocumentSequence к IDocumentPaginatorSource.

...