2011-12-20 73 views
0

我有一個視圖,其中包含一個DocumentViewer控件,並且我有另一個具有公開FixedDocumentSequence並實現INotifyPropertyChanged的屬性的類。我試圖將documentviewer的document屬性綁定到FixedDocumentSequence屬性,當我運行它時,documentviewer不會加載FixedDocumentSequence。視圖中的所有其他綁定正在工作,但不是這一個。數據綁定到DocumentViewer.Document屬性

這裏是代碼片段的任何幫助將不勝感激,希望這是我微不足道的僞造。

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

是Get叫什麼?嘗試返回IDocumentPaginatorSource。您應該能夠將_fixedDocumentSequence投射到IDocumentPaginatorSource。

+0

如果我在get上設置了一個斷點,它會在窗口第一次加載時觸發,但不在之後觸發。我用IDocumentPaginatorSource嘗試過,但沒有運氣,演員的作品,但結果是一樣的。 – jfin3204 2011-12-20 21:04:37

+0

您可以做的另一件事是創建一個帶有catch塊的pass through轉換器,並且有時會發現一個錯誤。你確定文件不只是空白? – Paparazzi 2011-12-20 22:15:42

+0

嘗試調用NotifyPropopertyChanged(「FixedDocumentSeq」);如果get只是在負載上調用,那麼你需要看看set。 – Paparazzi 2011-12-20 22:31:35