我需要幫助的元素統一大小的StackPanel統一在StackPanel的元件尺寸
void MainPageLoaded(object sender, RoutedEventArgs e)
{
var random = new Random();
for (var i = 0; i < 5; i++)
{
var grid = new Grid();
var border = new Border()
{
Height = random.Next(50, 150),
Width = random.Next(50, 150),
Margin = new Thickness(10),
BorderBrush = new SolidColorBrush(Colors.White),
BorderThickness = new Thickness(1)
};
grid.Children.Add(border);
imageBoxesStackPanel.Children.Add(grid);
}
VAR H = imageBoxesStackPanel.Children.Max(N => n.DesiredSize.Height);
我想要實現的是在stackpanel中查找每個網格的最大高度和最大寬度並將其應用於所有網格。問題是所需的尺寸總是錯誤的。
太棒了! UniformGrid完全做了我需要的!萬分感謝! – Jeff