简体   繁体   中英

How To save image in WPF Application in C#

Hi i am new in c# WPF i am creating a Diagram Maker application. 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. 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:

using Microsoft.Win32;

Sample:

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

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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