2010-09-01 25 views
0
<inf:WorkspaceContent.Resources> 
    <ResourceDictionary> 
     <commands:CommandReference x:Key="CompareCommandReference" Command="{Binding CompareCommand}"/> 
     <converters:FlowDocumentConverter x:Key="FlowDocConverter"/> 
    </ResourceDictionary> 
</inf:WorkspaceContent.Resources> 

<Grid x:Name="LayoutRoot"> 
    <Grid.RowDefinitions> 
     <RowDefinition/> 
     <RowDefinition Height="Auto"/> 
     <RowDefinition Height="Auto"/> 
    </Grid.RowDefinitions> 
    <Grid.ColumnDefinitions> 
     <ColumnDefinition Width="0.5*"/> 
     <ColumnDefinition Width="0.5*"/> 
    </Grid.ColumnDefinitions> 
    <RichTextBox x:Name="OrigText" Margin="0,0,8,0" d:LayoutOverrides="Width"> 
     <FlowDocument> 
      <Paragraph><Run Text="The fox jumped over the hill. The fox jumped over the mountain."/></Paragraph> 
      <Paragraph><Run Text=""/></Paragraph> 
     </FlowDocument> 
    </RichTextBox> 
    <Button x:Name="OrigFileBrowse" HorizontalAlignment="Center" Margin="0,0,8,2.442" Width="75" Content="Browse" Grid.Row="1" d:LayoutOverrides="Height"/> 
    <RichTextBox x:Name="ModifiedText" Grid.Column="1" Margin="8,0,0,0"> 
     <FlowDocument> 
      <Paragraph><Run Text="The fox junped over the hill. The fax jumped over the mountain."/></Paragraph> 
     </FlowDocument> 
    </RichTextBox> 
    <Button x:Name="ModifiedFileBrowse" HorizontalAlignment="Center" Width="75" Content="Browse" Grid.Row="1" Grid.Column="1" Margin="0,0,0,2.442" d:LayoutOverrides="Height"/> 
    <Button x:Name="Compare" Command="{StaticResource CompareCommandReference}" HorizontalAlignment="Center" VerticalAlignment="Top" Width="75" Content="Compare" Grid.Row="2" Grid.ColumnSpan="2"> 
     <Button.CommandParameter> 
      <MultiBinding Converter="{StaticResource FlowDocConverter}"> 
       <Binding Path="Document" ElementName="OrigText"/> 
       <Binding Path="Document" ElementName="ModifiedText"/> 
      </MultiBinding> 
     </Button.CommandParameter> 
    </Button> 
</Grid> 

上面是XAML的問題...我有一個按鈕,點擊它時,通過發佈在IEventAggregator棱鏡的事件,在其中傳遞的看法是什麼以上。轉換器然後觸發,並且這些值看起來合法。不過,我希望比較命令在上面被觸發時觸發。但是當這種情況發生時,對象[]有兩個項目都是空的......不知道是什麼導致了這個?與棱鏡/ RibbonControl MultiBinding導致轉換器火災早期

回答

0

這是設計。它將被緩存,因爲底層的FlowDocument引用不會更改。解決方法是將項目不作爲簡單對象[]而是作爲新定義的類型返回。一旦你這樣做,當比較命令執行時,這些值將通過參數返回。