I am writing a WPF Image Manager application. I have a ListBox with the following ItemsTemplate:
<Grid x:Name="grid" Width="150" Height="150" Background="{x:Null}">
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
<RowDefinition Height="27.45"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="150"/>
</Grid.ColumnDefinitions>
<Border Margin="5,5,5,5.745" Grid.RowSpan="2" Background="#FF828282" BorderBrush="{DynamicResource ListBorder}" CornerRadius="5,5,5,5" BorderThickness="1,1,2,2" x:Name="border">
<Grid>
<Viewbox Margin="0,0,0,21.705">
<Image Width="Auto" Height="Auto" x:Name="picture" Source="{Binding Path=FullName}" />
</Viewbox>
<TextBlock Height="Auto" Text="{Binding Path=Name}" TextWrapping="Wrap" x:Name="PictureText" HorizontalAlignment="Left" Margin="70,0,0,0" VerticalAlignment="Bottom" />
</Grid>
</Border>
</Grid>
Note that the Image control is bound to the FullName property, which is a string representing the absolute path to the JPG.
Some application features require you to modify the JPG file (move, rename, or delete). When I try to do this (currently trying to move the file), I get an IOException: "The process cannot access the file because it is being used by another process." The file locking process is my WPF application.
, , , , . :
- ListBox.Source null
- 10
.
- GC.Collect().
- .
? Image ItemsTemplate , , .
, , , , , , , .
.