我无法将按钮面板内的按钮移动到右边,我尝试了几个解决方案,毕竟我把它们放在堆叠面板上并试图将它们移动到右边,但acctualy他们不会移动任何地方,这里是它的外观:Wpf Dock Dock左边和Dock右边
这里是我的代码:
<GroupStyle>
<GroupStyle.ContainerStyle>
<Style TargetType="{x:Type GroupItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type GroupItem}">
<Expander IsExpanded="True" Background="Black" Opacity="0.7">
<Expander.Header>
<DockPanel Height="50">
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" DockPanel.Dock="Right"> <Button DockPanel.Dock="Right" Content="Test" Margin="0,0,28,0"/></StackPanel>
<StackPanel Orientation="Horizontal" VerticalAlignment="Center" DockPanel.Dock="Left"> <TextBlock FontWeight="Normal" FontFamily="Verdana" FontSize="20" Height="25" Foreground="#83D744" Text="{Binding Path=Name,StringFormat= Order Number:# {0}}" /></StackPanel>
</DockPanel>
</Expander.Header>
<Expander.Content>
<ItemsPresenter />
</Expander.Content>
</Expander>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</GroupStyle.ContainerStyle>
</GroupStyle>
</DataGrid.GroupStyle>
编辑:
这上面的原因宽度固定面板上
<DockPanel Height="50" Width="{Binding ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}">
<Button DockPanel.Dock="Right" Content="Test" Margin="0,0,28,0"/>
<TextBlock FontWeight="Normal" FontFamily="Verdana" FontSize="20" Height="25" Foreground="#83D744" Text="{Binding Path=Name,StringFormat= Order Number:# {0}}" />
</DockPanel>
它很可能是'Expander'将标题内容对齐到左侧。如果你需要改变它,你可以尝试从这里建议:http://stackoverflow.com/questions/680498/how-can-i-make-a-wpf-expander-stretch – ASh
如果我添加'宽度= {绑定 \t \t \t \t \t \t \t \t的RelativeSource = {的RelativeSource \t \t \t \t \t \t模式= FindAncestor, \t \t \t \t \t \t \t AncestorType = {X:式膨胀}}, \t \t \t \t \t \t \t \t路径= ActualWidth的}“>'我DockPanel中比我有问题,我的垂直滑块不会工作了,所以我不得不用鼠标滚动,让我的数据网格的底部,我媒体链接尝试这个 –