WPF DATAGRID ROW HEIGHT

E E Cummings

Total Post:26

Points:182
Posted by  E E Cummings
WPF 
WPF
 5545  View(s)
Ratings:
Rate this:
Hi mindstick!

I have a datagrid in a WPF project,

ive set the columns width to be have maximun limits,

and i want the data to be stretched in the rows them self but that doesnt happends...

they just stay as they are and the cell is cuted...

any ideas ?

Here is the code :

<DockPanel>

<DataGrid x:Name="nirGrid" x:Uid="nirGrid" AutoGenerateColumns="False"      AlternationCount="2" SelectionMode="Single" DockPanel.Dock="Top" Margin="10,50,10,50" FlowDirection="RightToLeft" ColumnWidth="SizeToCells" CanUserSortColumns="False" CanUserResizeColumns="False" CanUserReorderColumns="False" GridLinesVisibility="None" HeadersVisibility="None" SelectionUnit="Cell" VerticalAlignment="Stretch" EnableRowVirtualization="False" IsReadOnly="True" RowDetailsVisibilityMode="Visible" MinRowHeight="0" CanUserResizeRows="True" RowHeaderWidth="0">

        <DataGrid.Style>

            <Style>

                <Setter Property="ScrollViewer.CanContentScroll" Value="False" />

            </Style>

        </DataGrid.Style>

        <DataGrid.Columns >

            <DataGridTextColumn Binding="{Binding Path=task_desc}" IsReadOnly="True" Header="test1" Width="SizeToCells" MaxWidth="330" >

            </DataGridTextColumn>

            <DataGridTextColumn Binding="{Binding Path=task_req_date}" IsReadOnly="True" Header="test2" Width="SizeToCells" MaxWidth="70" >

            </DataGridTextColumn>

            <DataGridTemplateColumn Header="delete" >

                <DataGridTemplateColumn.CellTemplate>

                    <DataTemplate>

                        <Button Content="delete" ToolTip="delete" Opacity="0.8" Click="Button_Click" MouseEnter="Button_MouseEnter" MouseLeave="Button_MouseLeave">

                            <Button.Template>

                                <ControlTemplate>

                                    <Border HorizontalAlignment="Center" VerticalAlignment="Center">

                                        <Image Source="/exhibits;component/Images/exit1.png" Width="15" Height="15" />

                                    </Border>

                                </ControlTemplate>

                            </Button.Template>

                        </Button>

                    </DataTemplate>

                </DataGridTemplateColumn.CellTemplate>

            </DataGridTemplateColumn>

        </DataGrid.Columns>

    </DataGrid>

thanks in advance

  1. shreesh chandra shukla

    Post:105

    Points:735
    Re: WPF DataGrid row height

    Solution!

    try using the TextBlock I belive it should automatically wrap to your size

      <DataGridTemplateColumn Width="*" Header="Column 2">

                <DataGridTemplateColumn.CellTemplate>

                    <DataTemplate>

                        <TextBlock Text="{Binding Path=task_req_date}"" TextWrapping="Wrap" /> 

                    <DataTemplate>

                <DataGridTemplateColumn.CellTemplate>

            </DataGridTemplateColumn>

Answer

NEWSLETTER

Enter your email address here always to be updated. We promise not to spam!