本文介绍了Wpf Dock面板底座左侧和Dock右侧的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我不能把一个码头面板的按钮向右移动,我尝试过几个解决方案,毕竟我把它们放在堆栈面板上,试图把它们移到右边,但是它们不会移动到任何地方是怎么样的:这里是我的代码:
< GroupStyle>
< GroupStyle.ContainerStyle>
< Style TargetType ={x:Type GroupItem}>
< Setter Property =Template>
< Setter.Value>
< ControlTemplate TargetType ={x:Type GroupItem}>
< Expander IsExpanded =TrueBackground =BlackOpacity =0.7>
< Expander.Header>
< DockPanel Height =50>
< StackPanel Orientation =HorizontalVerticalAlignment =CenterDockPanel.Dock =Right> < Button DockPanel.Dock =RightContent =TestMargin =0,0,28,0/>< / StackPanel>
< StackPanel Orientation =HorizontalVerticalAlignment =CenterDockPanel.Dock =Left> < TextBlock FontWeight =NormalFontFamily =VerdanaFontSize =20Height =25Foreground =#83D744Text ={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 =50Width ={Binding ActualWidth,RelativeSource = {RelativeSource Mode = FindAncestor,AncestorType = DataGrid}}>
< Button DockPanel.Dock =RightContent =TestMargin =0,0,28,0/>
< TextBlock FontWeight =NormalFontFamily =VerdanaFontSize =20Height =25Foreground =#83D744Text ={Binding Path = Name,StringFormat = Order Number:#{0 }}/>
< / DockPanel>
解决方案
应用 Width ={绑定ActualWidth,RelativeSource = {RelativeSource Mode = FindAncestor,AncestorType = DataGrid}}
到您的 DockPanel
,看看是否解决了您的问题。 p>
I am not able to move buttons inside of a dock panel to the right, I tried few solutions, and after all I put them in stack panels and tried to move them to the right, but acctualy they wont move anywhere, here is how it looks:
And here is my code:
<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>
edit:
This above causes width on dock panel
<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>
解决方案
Apply Width="{Binding ActualWidth, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType=DataGrid}}"
to your DockPanel
and see if this solves your problem.
这篇关于Wpf Dock面板底座左侧和Dock右侧的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!