Quantcast
Channel: C#タグが付けられた新着記事 - Qiita
Viewing all articles
Browse latest Browse all 8899

ElementHostの子要素を参照する。[短小コード]

$
0
0

方法

// controlって引数でElementHostがobject型で渡ってきた前提。vareh=(System.Windows.Forms.Integration.ElementHost)control;varcc=(System.Windows.Controls.ContentControl)eh.Child;varpa=(System.Windows.Controls.Panel)cc.Content;// Gridである場合もあるかもしれませんね。System.Windows.Controls.UIElementCollectionchildren=pa.Children;// なお、確実にChildrenの第1要素がButtonである場合は以下のように取得できています。varbutton=(System.Windows.Controls.Button)children[0];

元ネタ:http://bbs.wankuma.com/index.cgi?mode=al2&namber=58626&KLOG=98

背景

かなり時間を吸われたので。

しかしなんでChildプロパティがContentControl型で定義されてないんだろう。このテが通用しないパターンもあるってことなんだろうか。


Viewing all articles
Browse latest Browse all 8899

Trending Articles