【问题标题】:How To save image in WPF Application in C#如何在 C# 中的 WPF 应用程序中保存图像
【发布时间】:2015-10-18 07:11:01
【问题描述】:

您好,我是 C# WPF 的新手,我正在创建一个图表制作应用程序。它只保存为 .xml 文件以便能够再次编辑,但我想将它也保存为图像,我搜索但他们使用的是 OpenFileDialog 并且 c# WPF 不支持 OpenFileDialog 命令。我在保存中有这样的代码。

<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>

我会怎么做?任何想法将不胜感激。 :)

【问题讨论】:

    标签: c# wpf image save


    【解决方案1】:

    WPF 有 OpenFileDialog... 在使用中:

    using Microsoft.Win32;
    

    示例:

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

    【讨论】:

    • 非常感谢@Spawn,现在我可以完成我的论文了。我只搜索jpg保存代码。
    • 可以在此处找到良好的图像保存示例,例如 - stackoverflow.com/a/4161485/1979354
    猜你喜欢
    • 2016-01-05
    • 1970-01-01
    • 1970-01-01
    • 2017-02-14
    • 1970-01-01
    • 2017-07-14
    • 2011-05-09
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多