とっちゃん's Blog

WindowsInstaller に WiX はいかがですか~

目次

Blog 利用状況

ニュース

とっちゃんって?

コミュニティ

@ITの記事

CodeZineの記事

WiX チュートリアル

Windows ユーザー エクスペリエンス ガイドライン

唯一の日本語書籍

記事カテゴリ

書庫

日記カテゴリ

インストーラ関連

旧館

フォルダ選択ダイアログを WPF アプリから呼び出す

前回は、Windows Forms 用だったので次は、WPF用。違うのはウィンドウハンドルを取得する方法だけ。

WPFアプリ用ですが、こちらは、XAMLからは呼べません。ファイルダイアログと同じですね。

 

ってことで、こちらもコードをペタッと。。。

using System;
using System.Windows;
using System.Windows.Interop;

namespace Wankuma.WPF
{
  public class PickupFolderDialog
  {
    public PickupFolderDialog()
    {
    }
    public String SelectedPath
    {
      get;
      set;
    }
    public bool ShowDialog( Window ownerWindow )
    {
      var hwndSrc = HwndSource.FromVisual( ownerWindow ) as HwndSource;
      return ShowDialog( hwndSrc.Handle );
    }
    public bool ShowDialog( IWin32Window ownerWindow )
    {
      return ShowDialog( (ownerWindow != null) ? ownerWindow.Handle : IntPtr.Zero );
    }
    public bool ShowDialog()
    {
      return ShowDialog( IntPtr.Zero );
    }
    private bool ShowDialog( IntPtr handle )
    {
      var dlg = new Wankuma.PickupFolderDialogCore();
      dlg.SelectedPath = this.SelectedPath;
      if( dlg.ShowDialog( handle ) )
      {
        this.SelectedPath = dlg.SelectedPath;
        return true;
      }
      return false;
    }
  }
}

使い方は、名前空間が違うだけで、Windows FormsでもWPFでも同じなので省略。

特筆するようなところもないと思います。

投稿日時 : 2013年4月27日 17:30

コメントを追加

# It's very easy to find out any matter on web as compared to books, as I found this post at this web site. 2019/04/05 14:00 It's very easy to find out any matter on web as co

It's very easy to find out any matter on web as compared to books,
as I found this post at this web site.

# Hello, i think that i saw you visited my website so i came to “return the favor”.I am trying to find things to improve my web site!I suppose its ok to use some of your ideas!! 2019/05/03 21:05 Hello, i think that i saw you visited my website s

Hello, i think that i saw you visited my website so i came to “return the favor”.I am trying to find things to improve my web site!I suppose its ok to use
some of your ideas!!

# I've been surfing on-line greater than 3 hours as of late, yet I never found any attention-grabbing article like yours. It is beautiful worth enough for me. In my view, if all website owners and bloggers made just right content as you probably did, the 2019/05/06 12:20 I've been surfing on-line greater than 3 hours as

I've been surfing on-line greater than 3 hours as of late, yet I never found any attention-grabbing article like yours.

It is beautiful worth enough for me. In my view, if all website
owners and bloggers made just right content as
you probably did, the net shall be much more useful than ever
before.

# Hi there it's me, I am also visiting this website daily, this site is in fact fastidious and the viewers are genuinely sharing good thoughts. 2019/05/29 7:19 Hi there it's me, I am also visiting this website

Hi there it's me, I am also visiting this website daily,
this site is in fact fastidious and the viewers are genuinely sharing
good thoughts.

# Wonderful article! We will be linking to this great article on our site. Keep up the great writing. 2019/06/02 19:49 Wonderful article! We will be linking to this grea

Wonderful article! We will be linking to this great article on our site.
Keep up the great writing.

# Very descriptive post, I loved that a lot. Will there be a part 2? 2019/06/07 13:35 Very descriptive post, I loved that a lot. Will th

Very descriptive post, I loved that a lot. Will there be
a part 2?

# This website was... how do you say it? Relevant!! Finally I have found something which helped me. Many thanks! 2019/06/08 19:08 This website was... how do you say it? Relevant!!

This website was... how do you say it? Relevant!! Finally I have found something which
helped me. Many thanks!

# I go to see everyday some web sites and information sites to read posts, except this website offers feature based content. 2019/09/08 3:13 I go to see everyday some web sites and informatio

I go to see everyday some web sites and information sites to read posts, except this website offers feature based content.

タイトル
名前
URL
コメント