0

I have datagrid that it's bound to datatable, the problem is that it shows each row with multiline form like:

enter image description here

XAML looks like:

<DataGrid    
     DataContext="{Binding DashBoardUCVM, Source={StaticResource Locator}}" 
     Foreground="Black"
     FontSize="16"                
     Background="White"
     IsReadOnly="True"
     SelectedIndex="{Binding SelectedIndexDDG}"
     SelectedValue="{Binding SelectionValueDDG}" 
     ItemsSource="{Binding JobsViewDG}">        
</DataGrid>

I have tried like this answer, and added RowHeight="50", but the I get:

enter image description here

i.e it shows only the top part of the content. I need something like:

enter image description here

BugsFixer
  • 377
  • 2
  • 15

2 Answers2

1

I don't quite completly understand what you want to acomplish here. But i think there is a problem with showing multiple lines in the datagrid.

As i see it, the problem is not the datagrid is the data you send. Try to process the data before passing it to the datagrid. What i normally do when the raw data does not fit me is use a DataTable. In the datatable I can modify it's value as I need it, withdraw or adding info does is a simple matter, and then i can pas it to the DataGrid by binding or simple passing it directly to it's ItemSource by DataTable.AsDataView().

PS: Be careful that the columns of the DataTAble and the DataGrid have to be binded between them (the datagrid column content must have the same binding name as the datatable header)

0

If I understand your problem correctly, you want to get rid of wrapping which can be achieved using:

<DataGrid ...>
<DataGrid.Resources>
    <Style TargetType="{x:Type TextBlock}">
        <Setter Property="TextWrapping" Value="NoWrap"/>
    </Style>
</DataGrid.Resources>
...

as found here WPF DataGrid Cell Text Wrapping - set to NoWrap (False)

You can specify width you are willing to start with and rest will be hidden on the right side of the column.

Piotr Moreń
  • 126
  • 5