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です...クリックすると、PrismのIEventAggregatorを介してイベントを公開するボタンがあり、ビューが渡されます。これは上記のとおりです。その後、コンバーターが起動し、値は正当に見えます。ただし、上記のcompareコマンドが実行された時点で比較を実行する必要があります。しかし、それが起こったとき、object []には両方ともnullの2つのアイテムがあります...これを引き起こしている原因がわかりませんか?

4

1 に答える 1

0

これは仕様によるものです。基になるFlowDocument参照は変更されないため、キャッシュされます。解決策は、アイテムを単純なobject []としてではなく、新しく定義されたタイプとして返​​すことです。これを行うと、Compareコマンドが実行されたときに、引数を介して値が返されます。

于 2010-09-09T17:14:25.463 に答える