dusm
dusm

Reputation: 1257

horizontal alignment to the right + wpf

i have a window wpf application, presenting a list of items. i would like the list to be presented to the right, and not to the left as it is at the moment. my partly xaml file is attached. i tried attaching the attribute horizontalalignment to the textblocks and the images, but nothing changed.

   <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>

i apriciate any help you can offer. thanks, hadas.

Upvotes: 1

Views: 1575

Answers (2)

Sandepku
Sandepku

Reputation: 861

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

You can introduce a grid just above the stackpanel and use Column # 1 for obtaining right alignment

Upvotes: 1

Mikl&#243;s Balogh
Mikl&#243;s Balogh

Reputation: 2202

Use DockPanel instead of StackPanel and try to set HorizontalContentAlignment

Upvotes: 0

Related Questions