Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
XAML Right Align Grid column
Message
De
08/01/2013 03:37:47
 
 
À
07/01/2013 13:31:52
Information générale
Forum:
ASP.NET
Catégorie:
Windows Presentation Foundation (WPF)
Divers
Thread ID:
01561611
Message ID:
01561694
Vues:
27
>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)
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform