1

我有一个窗口 wpf 应用程序,显示项目列表。我希望将列表显示在右侧,而不是像目前那样显示在左侧。附上我的部分 xaml 文件。我尝试将属性水平对齐附加到文本块和图像,但没有任何改变。

   <HierarchicalDataTemplate DataType="{x:Type cl:FolderData}" ItemsSource="{Binding Path=Children,UpdateSourceTrigger=PropertyChanged}">
    <Border BorderThickness="1">
        <!-- Drop="FolderStackPanel_PreviewDrop" -->
        <StackPanel DragEnter="StackPanel_PreviewDragEnter" DragLeave="StackPanel_PreviewDragLeave" 
                         Name="FolderStackPanel" Drop="FolderStackPanel_PreviewDrop" Orientation="Horizontal" ContextMenu="{StaticResource cmExportDelete}"
                    HorizontalAlignment="Right">
            <Image Name="NodeIcon" Width="24"  Margin="5" Height="24" Source="pack://application:,,,/ExportToolWpf;component/Images/folder_icon.png"/>
            <StackPanel Orientation="Vertical" Margin="0,5,0,0" >
                <TextBlock Name="NodeHeader" FontSize="11" Text="{Binding Path=FolderName}" />
                <StackPanel Name="IdPanel" Orientation="Horizontal">
                    <TextBlock FontSize="10" Foreground="Gray" Text="Client ID:" />
                    <TextBlock FontSize="10" Foreground="Gray" Text="{Binding Path=ClientId}" Margin="0,0,7,0" />
                    <TextBlock FontSize="10" Foreground="Gray" Text="Project ID:"/>
                    <TextBlock FontSize="10" Foreground="Gray" Text="{Binding Path=ProjectId}" />
                </StackPanel>
            </StackPanel>
        </StackPanel>
    </Border> </HierarchicalDataTemplate>

我感谢您提供的任何帮助。谢谢,哈达斯。

4

2 回答 2

1
<Grid>
 <Grid.ColumnDefinitions>
  <ColumnDefinition Width="*"/>
  <ColumnDefinition Width="Auto"/>
 </Grid.ColumnDefinitions>
 <StackPanel Grid.Column="1" />
</Grid>

您可以在堆栈面板上方引入一个网格并使用 Column #1 来获得右对齐

于 2012-09-21T04:09:28.043 回答
0

使用DockPanel代替StackPanel并尝试设置HorizontalContentAlignment

于 2012-09-20T09:29:36.647 回答