2012-04-23 61 views
0

我有一個顯示圖像的列表框,該列表給出用戶選項以使用默認圖像編輯器打開文件。在列表中圖像有一個工具提示,顯示圖像的更大版本。WPF圖像工具提示鎖定文件

我的問題是,當顯示工具提示時,圖像被鎖定,並且如果用戶試圖編輯圖像,當他試圖保存時,他會得到訪問共享違規。

的XAML是非常簡單的

<Image x:Name="_thumbImage" Source="{Binding Path}" >     
          <Image.ToolTip> 
           <Grid> 
            <Image Source="{Binding Path,BindsDirectlyToSource=True,IsAsync=False}" Stretch="Fill" HorizontalAlignment="Center" Height="300" Width="300"></Image> 
           </Grid> 
          </Image.ToolTip> 

         </Image> 

任何人知道如何解決這一問題?

回答

0

您可以明確地創建一個BitmapImage,它將圖像緩存在內存中並釋放文件。請注意,不需要兩次加載圖像,所以我將它放入資源中。

<Grid> 
    <Grid.Resources> 
    <BitmapImage x:Key="Source" UriSource="{Binding Path}" /> 
    </Grid.Resources>      
    <Image x:Name="_thumbImage" Source="{StaticResource Source}"> 
    <Image.ToolTip> 
     <Grid> 
     <Image Source="{StaticResource Source}" Stretch="Fill" 
       HorizontalAlignment="Center" 
       Height="300" Width="300"> 
     </Image> 
     </Grid> 
    </Image.ToolTip> 
    </Image> 
</Grid>