简体   繁体   English

如何在C#中的WPF应用程序中保存图像

[英]How To save image in WPF Application in C#

Hi i am new in c# WPF i am creating a Diagram Maker application. 嗨,我是c#WPF的新手,我正在创建一个Diagram Maker应用程序。 it only save as .xml file to be able to edit again, but i want to save it also as image, i searched but they are using OpenFileDialog and the c# WPF doesn't support the OpenFileDialog command. 它只另存为.xml文件,以便能够再次进行编辑,但是我想将其另存为图像,我进行了搜索,但他们使用的是OpenFileDialog,而c#WPF不支持OpenFileDialog命令。 I have a code like this in save. 我有这样的代码保存。

<Button Margin="1" Padding="2" HorizontalContentAlignment="Left"
                        Style="{StaticResource ToolBarButtonBaseStyle}"
                        Command="{x:Static ApplicationCommands.Save}"
                        CommandTarget="{Binding ElementName=MyDesigner}">
                    <Button.Content>
                        <Grid>
                            <Grid.ColumnDefinitions>
                                <ColumnDefinition/>
                                <ColumnDefinition />
                            </Grid.ColumnDefinitions>
                            <Image Source="Images/image.png" Width="16"/>
                            <TextBlock Margin="3,0,3,0" Text="Save" VerticalAlignment="Center" Grid.Column="1"/>
                        </Grid>
                    </Button.Content>
                </Button>

What will i do? 我该怎么办? Any ideas will be appreciated. 任何想法将不胜感激。 :) :)

WPF has OpenFileDialog... In usings: WPF具有OpenFileDialog ...在使用中:

using Microsoft.Win32;

Sample: 样品:

OpenFileDialog opf = new OpenFileDialog();
if (opf.ShowDialog().HasValue)
{
    string myFile = opf.FileName;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM