我無法將按鈕面板內的按鈕移動到右邊,我嘗試了幾個解決方案,畢竟我把它們放在堆疊面板上並試圖將它們移動到右邊,但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中比我有問題,我的垂直滑塊不會工作了,所以我不得不用鼠標滾動,讓我的數據網格的底部,我媒體鏈接嘗試這個 –