0

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. :)

1 Answers1

1

WPF has OpenFileDialog... In usings:

using Microsoft.Win32;

Sample:

OpenFileDialog opf = new OpenFileDialog();
if (opf.ShowDialog().HasValue)
{
    string myFile = opf.FileName;
}
Spawn
  • 935
  • 1
  • 13
  • 32
  • Thanks you very very much @Spawn, now i can finish my thesis program. i'll just search for the jpg save code. – Warren Razon Oct 18 '15 at 07:42
  • Good sample of image save can be found here, for example - http://stackoverflow.com/a/4161485/1979354 – Spawn Oct 18 '15 at 08:22