Home > DeveloperSection > Forums > WPF DataGrid row height
E E Cummings
E E Cummings

Total Post:26

Points:182
Posted on    July-19-2013 11:51 PM

 WPF WPF 
Ratings:


 1 Reply(s)
 4510  View(s)
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



shreesh chandra shukla
shreesh chandra shukla

Total Post:105

Points:735
Posted on    July-19-2013 11:56 PM

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>


Don't want to miss updates? Please click the below button!

Follow MindStick