IsSharedSizeScope 在 Grid(parent) 级别中设置为 true,StackPanel 作为子级,然后 IsSharedSizeScope 属性不起作用,但是当我删除 StackPanel 时它起作用。我试图了解我做错了什么。任何帮助,将不胜感激。
<Window x:Class="DemoWpfApp.Views.PortConnectionView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:local="clr-namespace:DemoWpfApp.Views"
xmlns:vm="clr-namespace:DemoWpfApp.ViewModels"
mc:Ignorable="d"
d:DesignHeight="450" d:DesignWidth="800">
<Window.DataContext>
<vm:PortConnectionViewModel/>
</Window.DataContext>
<Grid Grid.IsSharedSizeScope="True">
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto" SharedSizeGroup="A"/>
<ColumnDefinition Width="Auto" SharedSizeGroup="A"/>
<ColumnDefinition Width="Auto" SharedSizeGroup="A" />
</Grid.ColumnDefinitions>
<StackPanel Grid.Row="1" Orientation="Horizontal" Margin="3">
<TextBlock Grid.Column="0" Text="Detect charger" Margin="3" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Grid.Column="1" Text="Ok" Margin="3" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
<StackPanel Grid.Row="2" Orientation="Horizontal" Margin="3">
<TextBlock Grid.Column="0" Text="Configure meter" Margin="3" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Grid.Column="1" Text="Ok" Margin="3" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
<StackPanel Grid.Row="3" Orientation="Horizontal" Margin="3">
<TextBlock Grid.Column="0" Text="Activate charger" Margin="3" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Grid.Column="1" Text="Ok" Margin="3" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
<StackPanel Grid.Row="4" Orientation="Horizontal" Margin="3">
<TextBlock Grid.Column="1" Text="Upgrade version" Margin="3" HorizontalAlignment="Center" VerticalAlignment="Center"/>
<TextBlock Grid.Column="2" Text="Ok" Margin="3" HorizontalAlignment="Center" VerticalAlignment="Center"/>
</StackPanel>
</Grid>
</Window>