从 WPF 中的 Image 标记修改图像
我有一个显示一堆图像的表单。我希望能够通过另一个可执行文件(例如 Paint)修改此图像,并在退出时刷新图像(例如通过按钮)。
当我尝试将图像保存在油漆中时,它告诉我图像受到保护,这是由于表单以某种方式链接到图像。
有什么办法可以让这个工作吗?知道如何绕过这个问题吗?
谢谢。
编辑:这是我使用的结构(高度简化)
<ListView Style="{StaticResource BaseListView}" x:Name="LstMoulures" Grid.Column="0" Background="#00000000" SelectionMode="Single" IsTextSearchEnabled="False" ScrollViewer.VerticalScrollBarVisibility="Auto">
<ListView.ItemTemplate>
<DataTemplate>
<Border BorderBrush="White" Margin="1,1,1,1" BorderThickness="2,2,2,2" CornerRadius="4">
<StackPanel Orientation="Horizontal" Margin="5,0,0,5" Height="200">
<Image x:Name="ImgPicture" Width="220" Height="195" Margin="2,5,2,2" GotFocus="ImgPicture_GotFocus" MouseLeftButtonDown="ImgPicture_MouseLeftButtonDown" MouseEnter="ImgPicture_MouseEnter" MouseLeave="ImgPicture_MouseLeave">
<Image.Source>
<BitmapImage UriSource="{Binding DessinSource}" CacheOption="OnLoad" />
</Image.Source>
</Image>
</StackPanel>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
I have a form in which I display a bunch of image. I would like to be able to modify this image via another executable like paint and refresh the image when I quit (via a button for example).
When I try to save the image in paint,it tells me the image is protected, which is due to the form being somehow linked to the image.
is there any way to make this work ? Any idea how to bypass the problem ?
Thanks.
Edit : Here is the strucure (heaviliy simplified) I use
<ListView Style="{StaticResource BaseListView}" x:Name="LstMoulures" Grid.Column="0" Background="#00000000" SelectionMode="Single" IsTextSearchEnabled="False" ScrollViewer.VerticalScrollBarVisibility="Auto">
<ListView.ItemTemplate>
<DataTemplate>
<Border BorderBrush="White" Margin="1,1,1,1" BorderThickness="2,2,2,2" CornerRadius="4">
<StackPanel Orientation="Horizontal" Margin="5,0,0,5" Height="200">
<Image x:Name="ImgPicture" Width="220" Height="195" Margin="2,5,2,2" GotFocus="ImgPicture_GotFocus" MouseLeftButtonDown="ImgPicture_MouseLeftButtonDown" MouseEnter="ImgPicture_MouseEnter" MouseLeave="ImgPicture_MouseLeave">
<Image.Source>
<BitmapImage UriSource="{Binding DessinSource}" CacheOption="OnLoad" />
</Image.Source>
</Image>
</StackPanel>
</Border>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您还可以读取该文件并将其重写为
MemoryStream
对象:要监视图像更改并刷新图像,您可以使用
FileSystemWatcher
Also you can read the file and rewrite it to a
MemoryStream
object:For monitoring image changes and refreshing the image you can use
FileSystemWatcher