WPF 宽度跟父控件(或者另一个控件)走
<UserControl
Width="{Binding RelativeSource=
{RelativeSource FindAncestor,
AncestorType={x:Type ListView}},
Path=ActualWidth}"
Height="{Binding RelativeSource=
{RelativeSource FindAncestor,
AncestorType={x:Type ListView}},
Path=ActualHeight}">
<!-- Content -->
</UserControl>
<hc:ScrollViewer x:Name="scrList" > <WrapPanel Orientation="Horizontal" Width="{Binding ElementName=scrList, Path=Width, Mode=OneWay}" HorizontalAlignment="Center">
注意绑定 Mode = OneWay(a => b, b ≠> a)
浙公网安备 33010602011771号