gpt4 book ai didi

c# - 将 stackPanel 的最后一项水平附加到右侧

转载 作者:行者123 更新时间:2023-11-30 17:54:07 25 4
gpt4 key购买 nike

在我的 WPF 应用程序中,我创建了一个带有 orientation=horizo​​ntal 堆栈面板的停靠面板。

我在堆栈面板上添加了一些按钮(比如工具栏)

我希望能够将堆栈面板上的最后一项设置为附加到窗口右侧。

一些图片来解释。

我有什么:

enter image description here

我想要的:

enter image description here

这是我的 XAML:

<DockPanel  Height="40" VerticalAlignment="Top" >
<Border>

<StackPanel Orientation="Horizontal" Background="{StaticResource DegradeCouleurTheme}">

<Image Source="ElipseGauche.png" Height="28" Margin="10,0,0,0" />

<StackPanel Orientation="Horizontal" Height="28">

<StackPanel.Background>
<ImageBrush ImageSource="ElipseMilieu.png"></ImageBrush>
</StackPanel.Background>

<Button Template="{StaticResource BoutonRessourcesTpl}" Click="Button_Click_Goto_Premier">
<Image Source= "xRtDiva_XWPF_TBR_PREMIER.PNG_IMAGES.png" Height="16"/>
</Button>

<Button Template="{StaticResource BoutonRessourcesTpl}" Click="Button_Click_Goto_Precedent">
<Image Source= "xRtDiva_XWPF_TBR_PRECED.PNG_IMAGES.png" Height="16"/>
</Button>

<Button Template="{StaticResource BoutonRessourcesTpl}" Click="Button_Click_Goto_Suivant">
<Image Source= "xRtDiva_XWPF_TBR_SUIVANT.PNG_IMAGES.png" Height="16"/>
</Button>

<Button Template="{StaticResource BoutonRessourcesTpl}" Click="Button_Click_Goto_Dernier">
<Image Source= "xRtDiva_XWPF_TBR_DERNIER.PNG_IMAGES.png" Height="16"/>
</Button>

</StackPanel>

<Image Source="ElipseDroite.png" Height="28" Margin="0,0,0,0" />


<Image Source="ElipseGauche.png" Height="28" Margin="15,0,0,0" />

<StackPanel Orientation="Horizontal" Height="28">

<StackPanel.Background>
<ImageBrush ImageSource="ElipseMilieu.png"></ImageBrush>
</StackPanel.Background>

<Button Template="{StaticResource BoutonRessourcesTpl}" Click="Button_Click_Creer" >
<Image Source= "Toolbar_Creer.png" Height="16" />
</Button>

</StackPanel>

<Image Source="ElipseDroite.png" Height="28" Margin="0,0,0,0" />

<Image Source="ElipseGauche.png" Height="28" Margin="15,0,0,0" />


<StackPanel Orientation="Horizontal" Height="28">

<StackPanel.Background>
<ImageBrush ImageSource="ElipseMilieu.png"></ImageBrush>
</StackPanel.Background>

<Button Template="{StaticResource BoutonRessourcesTpl}" Click="Button_Click_Evenement_Supprimer">
<Image Source= "Toolbar_Supprimer.png" Height="16"/>
</Button>

</StackPanel>

<Image Source="ElipseDroite.png" Height="28" Margin="0,0,0,0" />

<Image Source="ElipseGauche.png" Height="28" Margin="15,0,0,0" />


<StackPanel Orientation="Horizontal" Height="28">

<StackPanel.Background>
<ImageBrush ImageSource="ElipseMilieu.png"></ImageBrush>
</StackPanel.Background>

<Button Template="{StaticResource BoutonRessourcesTpl}" Click="Button_Click_Evenement_Joints">
<Image Source= "Toolbar_FicJoints.png" Height="18"/>
</Button>

</StackPanel>

<Image Source="ElipseDroite.png" Height="28" Margin="0,0,0,0" />

<Image Source="ElipseGauche.png" Height="28" Margin="15,0,0,0" />


<StackPanel Orientation="Horizontal" Height="28">

<StackPanel.Background>
<ImageBrush ImageSource="ElipseMilieu.png"></ImageBrush>
</StackPanel.Background>

<Button Template="{StaticResource BoutonRessourcesTpl}" Click="Button_Click_Evenement_Annuler" >
<Image Source= "Toolbar_Annuler.png" Height="16"/>
</Button>

<Button Template="{StaticResource BoutonRessourcesTpl}" Click="Button_Click_Evenement_Valider">
<Image Source= "Toolbar_Valider.png" Height="16"/>
</Button>

</StackPanel>

<Image Source="ElipseDroite.png" Height="28" Margin="0,0,0,0" />



<Image Source="ElipseGauche.png" Height="28" Margin="15,0,0,0" />


<StackPanel Orientation="Horizontal" Height="28">

<StackPanel.Background>
<ImageBrush ImageSource="ElipseMilieu.png"></ImageBrush>
</StackPanel.Background>

<Button Template="{StaticResource BoutonRessourcesTpl}" Click="Button_Click_App_Parametrer" >
<Image Source= "Toolbar_Parametrer.png" Height="16"/>
</Button>

</StackPanel>

<Image Source="ElipseDroite.png" Height="28" Margin="0,0,0,0" />

<Grid HorizontalAlignment="Right">
<StackPanel Orientation="Horizontal" Height="28" >
<Image Source="ElipseGauche.png" Height="28" Margin="15,0,0,0" />


<StackPanel Orientation="Horizontal" Height="28">

<StackPanel.Background>
<ImageBrush ImageSource="ElipseMilieu.png"></ImageBrush>
</StackPanel.Background>

<Button Template="{StaticResource BoutonRessourcesTpl}" Click="Button_Click_About" >
<Label Margin="0,0,0,1" Foreground="White" Content="About" Height="16" VerticalAlignment="Center" HorizontalAlignment="Center" Padding="0,0,0,0"/>
</Button>

</StackPanel>

<Image Source="ElipseDroite.png" Height="28" Margin="0,0,0,0" />
</StackPanel>
</Grid>


</StackPanel>

</Border>
</DockPanel>

我尝试在堆栈面板的最后一项上使用 horizo​​ntalaligneemnt = right 的网格,但它没有效果(这是合乎逻辑的!)

有人可以帮帮我吗?

非常感谢:)

最佳答案

您不能使用 StackPanel 执行此操作。您需要改用 DockPanelGrid

关于c# - 将 stackPanel 的最后一项水平附加到右侧,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/16319271/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com