トップ回答者
C#、VB.NET用のコントロールをWPFから操作したい

質問
-
お世話になります。
こんなことは可能でしょうか?
WPF外で作られたコントロールがあります。
それをWPFのコントロール上で使いたいのです。
具体的にいいますと、以下のようなフリーのコントロールがあります。
以下は、C#、VB.NET用の縦書きが出来るのテキストボックスです。
http://www.vector.co.jp/soft/winnt/prog/se395668.html
これをWPFのLabel or TextBlockの上に貼り付けて表示、WPFから操作したいと考えております。
こういったことは可能でしょうか?DLLなので可能とは思いますが・・・具体的な方法が分かりません。
良ければヒントだけでもお願いいたします。
※WPFで縦書きのコントロールが見当たらないため、このようなことを考えましたorz 元々は、縦書き入力がしたいだけです。。。- 編集済み sumi_sumi 2012年8月29日 1:01
回答
-
VS2010の環境ですが、とりあえず動くものが出来たので・・・
<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:tt="clr-namespace:Alapon.Controls.TextBox;assembly=TateBox" Title="Window1" Height="300" Width="300"> <Grid> <WindowsFormsHost> <tt:TateBox Text="縦書き"/> </WindowsFormsHost> </Grid> </Window>
>> xmlns:tt="clr-namespace:Alapon.Controls.TextBox.TateBox;assembly=Alapon.Controls.TextBox.TateBox"
これを
xmlns:tt="clr-namespace:Alapon.Controls.TextBox;assembly=TateBox"
に書き換えてみてください。
- 回答としてマーク sumi_sumi 2012年8月31日 7:38
すべての返信
-
WPF外で作られたコントロールがあります。それをWPFのコントロール上で使いたいのです。
WindowsFormsHost を使えば WindowsForms で作られたコントロールをWPF のWindow に表示可能です。
※WPFで縦書きのコントロールが見当たらないため、このようなことを考えましたorz 元々は、縦書き入力がしたいだけです。。。
縦書きについてはこういう記事があります。
http://d.hatena.ne.jp/hilapon/20101128/1295710863
ひらぽん http://d.hatena.ne.jp/hilapon/
-
お世話になります。
MSの記事にXAMLサンプルがありましたので、まずそれを動かしました。その後、それを元に以下のようにしてみましたが、エラーが表示されます。
<Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms" xmlns:tt="clr-namespace:Alapon.Controls.TextBox.TateBox;assembly=Alapon.Controls.TextBox.TateBox" Title="Window1" Height="300" Width="300"> <Grid> <WindowsFormsHost> <tt:TateBox Text="縦書き"/> </WindowsFormsHost> </Grid> </Window>
エラーメッセージ↓
エラー 1 タグ 'TateBox' は、XML 名前空間 'clr-namespace:Alapon.Controls.TextBox;assembly=Alapon.Controls.TextBox' にありません。
行 9 位置 14. C:\Documents and Settings\USER\デスクトップ\PG\WPFサンプル\051_WindowsフォームコントロールをWPF要素に配置する\WpfApplication1\Window1.xaml 9 14 WpfApplication1
TateBoxへの参照が正しくないのかな?とは思い、以下の一行を色々さわってますが変わりません。
以下が正しくなかったでしょうか?
xmlns:tt="clr-namespace:Alapon.Controls.TextBox;assembly=Alapon.Controls.TextBox"- 編集済み sumi_sumi 2012年8月29日 1:46
-
そのassemblyであるdll、もしくはプロジェクトは、WpfApplication1プロジェクトで正しく参照設定されていますか?
★良い回答には回答済みマークを付けよう! わんくま同盟 MVP - Visual C# http://d.hatena.ne.jp/trapemiya/
- 編集済み trapemiyaModerator 2012年8月29日 2:07
-
Alaponはどこで見つけられたのでしょうか? 私の方で探してみましたが、わかりませんでした。
わかれば私の方でも試してみたいと思います。#Alaponは「ひらぽん」と似ていますが、ひらぽんさんが作られたものなのでしょうか??
いえ、違います ^^;
たぶんこれではないでしょうか?
http://www.vector.co.jp/soft/winnt/prog/se395668.html
#(追記)最初の質問で提示されてましたね。失礼しました。<(_ _;)>
ひらぽん http://d.hatena.ne.jp/hilapon/
- 編集済み ひらぽんModerator 2012年8月30日 4:25
-
VS2010の環境ですが、とりあえず動くものが出来たので・・・
<Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:tt="clr-namespace:Alapon.Controls.TextBox;assembly=TateBox" Title="Window1" Height="300" Width="300"> <Grid> <WindowsFormsHost> <tt:TateBox Text="縦書き"/> </WindowsFormsHost> </Grid> </Window>
>> xmlns:tt="clr-namespace:Alapon.Controls.TextBox.TateBox;assembly=Alapon.Controls.TextBox.TateBox"
これを
xmlns:tt="clr-namespace:Alapon.Controls.TextBox;assembly=TateBox"
に書き換えてみてください。
- 回答としてマーク sumi_sumi 2012年8月31日 7:38