SilverLight-Border-高度自适应
如下图:
框1、框2和框3总高度固定,框1、框2高度不固定,要求框3的高度自适应。
实现方法:
注册Border1、Border2的SizeChanged 事件,可以获得Border1、Border2的NewSize。然后可以算出Border3的高度。
double h1=0, h2=0,allh=708;
private void Border1_SizeChanged(object sender, SizeChangedEventArgs e)
{
Size newsize = e.NewSize;
h1 = newsize.Height;
Border3.Height = allh - h1 - h2;
}
private void Border2_SizeChanged(object sender, SizeChangedEventArgs e)
{
Size newsize = e.NewSize;
h2 = newsize.Height;
Border3.Height = allh - h1 - h2;
}
private void Border1_SizeChanged(object sender, SizeChangedEventArgs e)
{
Size newsize = e.NewSize;
h1 = newsize.Height;
Border3.Height = allh - h1 - h2;
}
private void Border2_SizeChanged(object sender, SizeChangedEventArgs e)
{
Size newsize = e.NewSize;
h2 = newsize.Height;
Border3.Height = allh - h1 - h2;
}
作者:青羽