ウィンドウが表示される前に(たとえば、ウィンドウコンストラクターで)、(グリッドの中央のセルにある)StackPanel widthを計算しようとしています。heightどのようにそれを達成することができますか?
<Window x:Class="WpfApplication2.TestWindow"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="TestWindow" Height="300" Width="300">
<Grid Name="grid">
    <Grid.ColumnDefinitions>
        <ColumnDefinition></ColumnDefinition>
        <ColumnDefinition></ColumnDefinition>
        <ColumnDefinition></ColumnDefinition>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition></RowDefinition>
        <RowDefinition></RowDefinition>
        <RowDefinition></RowDefinition>
    </Grid.RowDefinitions>
    <StackPanel Grid.Row="1" Grid.Column="1" Name="stackPanel"></StackPanel>
</Grid>
stackPanelセットDesiredSizeと同様にWindowを測定します{0;0}
public partial class TestWindow : Window
{
    public TestWindow()
    {
        InitializeComponent();
        this.Measure(new Size(this.Width, this.Height)); // -> this.DesiredSize = {0;0}
        ...
    }
}
編集1
FixedPageでは次のように機能します。
fixedPage.Measure(new Size(double.PositiveInfinity, double.PositiveInfinity)); 
fixedPage.Arrange(new Rect(0, 0, fixedPage.DesiredSize.Width, fixedPage.DesiredSize.Height));
次に、にアクセスできstackPanel.ActualWidthますstackpanel.ActualHeight。
ただし、ウィンドウの場合は機能しません。