1
我想添加圖像到WrapPanel,我希望看到所有這些都不滾動。添加新的小孩時,我正在調整圖像大小。 我有一個繼承自WrapPanel
的類,當添加子時,Resize()將被觸發。這裏是代碼:適合沒有滾動條的WrapPanel的所有孩子
public void Resize()
{
int c = this.Children.Count;
int d = 1;
if (c <= 4 && c>1) d = 2;
else if (c <= 9 && c>4) d = 3;
else if (c <= 16 && c > 9) d = 4;
foreach (UIElement child in this.Children)
{
dynamic ctrl = child;
ctrl.Width = this.Width/d;
}
}
這是最好的方法嗎?
如何使用'UniformGrid',這樣你只需要根據你擁有的圖片數量來設置行數/列數量,並且它會將它們全部縮放以適合。 – 2013-03-20 01:35:48
我喜歡它。謝謝sa_ddam213 – Dilshod 2013-03-20 01:49:05