像这样的东西怎么样:
您的 StackPanel 应如下所示:
<StackPanel Orientation="{Binding DockableStyle,
RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Avalon:DockableContent}},
Converter={StaticResource MyConverter}">
<!-- StackPanel content here -->
</StackPanel>
您Myconverter
具有以下Convert
方法:
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
DockableStyle style = value as DockableStyle
if (style == DockableStyle.TopBorder || style == DockableStyle.BottomBorder)
{
return Orientation.Horizontal;
}
else
{
return Orientation.Vertical;
}
}
我认为这应该为你做所有的魔法