Visual C#:找不到列表框的正确相对宽度

Visual C#: Can't find correct relative width for listbox

所以我有一个列表框,我正在尝试在其中使用堆栈面板作为带边框的项目。现在我希望每个项目都与我的列表框宽度相同,列表框固定在 window 的两侧。我找到了如何设置相对于父级的宽度,但由于某种原因它变得更宽了。似乎无法弄清楚为什么。下面的图片显示了它的外观。

<ListBox x:Name="listBoxSecrets" Margin="10,107,10,10" Background="{x:Null}">
    <ListBox.ItemTemplate>
        <DataTemplate>
            <Border BorderBrush="Orange" CornerRadius="2,2,2,2" BorderThickness="2,2,2,2">
                <StackPanel Background="White" 
                            Width="{Binding RelativeSource=
        {RelativeSource FindAncestor,
        AncestorType={x:Type ListBox}},
        Path=ActualWidth}"
                            >
                    <TextBlock Text="{Binding Path=Name}" />
                    <TextBlock Text="{Binding Path=Totp}" />
                </StackPanel>
            </Border>
        </DataTemplate>
    </ListBox.ItemTemplate>
</ListBox>

ListBox.ActualWidth 对于 ListBoxItems 来说太多了。但如果 ListBox 将 HorizontalContentAlignment 设置为 "Stretch",ListBoxItems 将使用所有可用宽度:

<ListBox HorizontalContentAlignment="Stretch"