最近の研究WPFプログラミング、変更のフォームを追跡するための制御をできるように学びます。ちょうど私を許して彼のようにも書き始めました!
主に二つの方法がありますが、
1、ラベル、画像、テキストボックス、単独カット制御は、より少ないビューボックスを追加することができます。
あなたはマルチの動作を制御したい場合は2、あなたは内部のCSに付属のコードを書くために(というマージンより、canvans.leftを使用してcanvans.top位置決め、キャンバス内のXAMLを追加注意してください)ウィンドウが身体をコントロール横断する必要があります。以下
開いたときに、フォームの初期サイズを取得します。
xvalues = this.ActualWidth。
yvalues = this.ActualHeight。
SetTag(gd_mode.Children)。
プライベートボイドSetTag(UIElementCollectionのUicontrol)
{
typecon [0] = textBoxMaxSet。
typecon [1] = textBox1テキストボックス。
typecon [2] = txt_result。
typecon [3] = TextBox2を。
typecon [4] = button_Set。
foreachの(制御I typeconで)
{
CON = I。
con.Tag = con.Width + ":" + con.Height + ":" + Canvas.GetLeft(CON)+ ":" + Canvas.GetTop(CON)+ ":" + con.FontSize。
}
}
フォームで内側に書かれWindow_SizeChanged
(!xvalues = 0)の場合
{
ダブルnewX = this.ActualWidth / xvalues。
ダブルnewY = this.ActualHeight / yvalues。
SetControls(newX、newY、gd_mode.Children)。
}
プライベート無効SetControls(ダブルnewX、ダブル newY、UIElementCollectionのuicontrolは)// コントロールのサイズを変更します
{
foreachの(制御I typeconで)
{
CON = I;
文字列[] mytagという= con.Tag.ToString()スプリット(新しい文字[] { ''})。
ダブルA = Convert.ToSingle(mytagという[0])* newX。
con.Width =(INT)。
= Convert.ToSingle(mytagという[1])* newY。
con.Height =(INT)。
= Convert.ToSingle(mytagという[2])* newX。
con.SetValue(Canvas.LeftProperty、(ダブル)A)。
= Convert.ToSingle(mytagという[3])* newY。
con.SetValue(Canvas.TopProperty、(ダブル)(a)参照)。
二重currentSize = Convert.ToSingle(mytagという[4])* newY。
con.FontSize = currentSize。
}
}