zoukankan      html  css  js  c++  java
  • WPF中的对话框(Dialog)

    在WPF中,系统定义的对话框(Dialog)有三种:
    (1)Microsoft.Win32.OpenFileDialog
    (2)Microsoft.Win32.SaveFileDialog
    (3)System.Windows.Controls.PrintDialog

    先看看前面两种的层次继承关系:
    System.Object
      Microsoft.Win32.CommonDialog
        Microsoft.Win32.FileDialog
          Microsoft.Win32.OpenFileDialog
          Microsoft.Win32.SaveFileDialog

    我们看到,这两种对话框均位于Microsoft.Win32命名空间中,它们均继承自Microsoft.Win32.FileDialog。

    (1)OpenFileDialog:
    OpenFileDialog有一种公共事件:FileOk(当用户选择文件名,点击打开按钮时发生)

    OpenFileDialog有以下几种公共方法
     OpenFile():打开单个文件
     OpenFiles():打开多个文件
     Reset():重置
     ShowDialog():显示对话框

    OpenFileDialog的公共属性有:
     .AddExtension,
     .CheckFileExists,
     .CheckPathExists,
     .DefaultExt,
     .DereferenceLinks,
     .FileName,
     .FileNames,
     .Filter,
     .FilterIndex,
     .InitialDirectory,
     .Multiselect,
     .ReadOnlyChecked,
     .RestoreDirectory,
     .SafeFileName,
     .SafeFileNames,
     .ShowReadOnly,
     .Tag,
     .Title,
     .ValidateNames
    其中,我们最常用的有: FileName, FileNames, Filter, FilterIndex, DefaultExt,InitialDirectory等。

    (2) SaveFileDialog:
    与OpenFileDialog类似,SaveFileDialog公共方法
     OpenFile()
     Reset()
     ShowDialog()
    公共属性:
     .AddExtension,
     .CheckFileExists,
     .CheckPathExists,
     .CreatePrompt,
     .DefaultExt,
     .DereferenceLinks,
     .FileName,
     .FileNames,
     .Filter,
     .FilterIndex,
     .InitialDirectory,
     .OverwritePrompt,
     .RestoreDirectory,
     .SafeFileName,
     .SafeFileNames,
     .Tag,
     .Title,
     .ValidateNames

    说明:在WPF中的Microsoft.Win32.OpenFileDialog,Microsoft.Win32.SaveFileDialog与在WinForm中的System.Windows.Forms.OpenFileDialog, System.Windows.Forms.SaveFileDialog用法上基本上一样,但前者由于WPF的限制,无法在Windows Server 2000 SP4, Windows Millennium Edition, Windows 98, Windows CE下使用。

    再看看看PrintDialog:
    (3)PrintDialog:
    看看它的继承关系:
    System.Object
      System.Windows.Controls.PrintDialog

    需要注意的是:不要将System.Windows.Controls.PrintDialog与System.Windows.Forms.PrintDialog混淆了,后者用于WinForm应用程序中。System.Windows.Controls.PrintDialog则用于Windows Presentation Foundation (WPF)应用程序中。
     

  • 相关阅读:
    论文Objects as Points的解读
    图像增强
    from __future__ import absolute_import作用
    python降级
    conda命令总是出现Solving environment: failed错误
    ResNet网络结构
    卷积与池化操作后特征图大小的计算
    vs2015安装包下载与安装教程
    每隔几秒检测进程是否挂了
    阿里云部署flask
  • 原文地址:https://www.cnblogs.com/luluping/p/2605775.html
Copyright © 2011-2022 走看看