Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
XAML Right Align Grid column
Message
From
08/01/2013 03:37:47
 
 
To
07/01/2013 13:31:52
General information
Forum:
ASP.NET
Category:
Windows Presentation Foundation (WPF)
Miscellaneous
Thread ID:
01561611
Message ID:
01561694
Views:
28
>Viv,
>
>I cannot reply to that thread for some reason, the buttons to reply are missing from the bottom.
>
>I had obviously not put the resources in the right place.
>
>Thanks for the suggested code. However it dd not change the alignment. This is my actual code:
>
>
                        <DataGrid AutoGenerateColumns="False" Grid.Row="5" Grid.Column="1" Height="Auto" HorizontalAlignment="Stretch" Margin="0" Name="grdInvoiceDetails" VerticalAlignment="Stretch" Width="Auto" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding Mode=default}" SelectionMode="Single" GridLinesVisibility="None" HeadersVisibility="Column" Grid.ColumnSpan="2" Style="{DynamicResource HDSDataGridStyle}" CanUserAddRows="False" CanUserDeleteRows="False" SelectionUnit="Cell" Grid.RowSpan="1">
>                            <DataGrid.Resources>
>                                <Style x:Key="AlignRight" TargetType="DataGridCell">
>                                    <Setter Property="HorizontalContentAlignment" Value="Right" />
>                                </Style>
>                            </DataGrid.Resources>
>                            <DataGrid.Columns>
>                                <DataGridComboBoxColumn Header="Charge Type" Width="*" DisplayMemberPath="cty_name" SelectedValuePath="cty_pk" SelectedValueBinding="{Binding ivd_ctyfk, Mode=Default}"/>
>
>                                <DataGridTextColumn Header="Amount" Width="*" Binding="{Binding ivd_amount, Mode=default}"
>                                                    CellStyle="{StaticResource AlignRight}"/>
>                            </DataGrid.Columns>
>                        </DataGrid>
>
>later:
>
>If I use HorizontalAlignment rather than HorizontalContentAlignment it works!

Ah, Sorry - see that I used HorizontalAlignment in one version and HorizontalContentAlignment in the other :-{

If you might need this behaviour on the same type of control throughout the app then it's worth actually putting in it a resource dictionary. Main bonus of using a resource dictionary is that you can set application wide styles allowing you to change the overall appearance of the app in one place (ala CSS in html)
Previous
Reply
Map
View

Click here to load this message in the networking platform