Codey
Codey

Reputation: 507

How to Control Sequence of columns automatically Generated in DataGrid

I have DataGrid, it looks like:

enter image description here

But I want it to be like:

enter image description here

I tried to add FlowDirection="RightToLeft", but then it looks like:

enter image description here

XAML:

<DataGrid FlowDirection="RightToLeft" ItemsSource="{Binding TableComments}" x:Name="dataGrid">
    <DataGrid.Columns >
        <DataGridTemplateColumn >
            <DataGridTemplateColumn.CellTemplate >
                <DataTemplate>
                    <Button  Command="{Binding DataContext.AddCommand, ElementName=dataGrid}" 
                CommandParameter="{Binding SelectedItems, ElementName=dataGrid}">Add</Button>
                </DataTemplate>
            </DataGridTemplateColumn.CellTemplate>
        </DataGridTemplateColumn>
    </DataGrid.Columns>
</DataGrid>

How to achive the result that I want? i.e buttons to the right, and other columns to the left( and their content's horizontalalign to left)

Upvotes: 0

Views: 118

Answers (1)

user11595360
user11595360

Reputation:

You can set DataGrid property

AutoGenerateColumns="False"

And manually add comment column. And from this point you are free of customization.

Upvotes: 2

Related Questions