GridViewDataColumn's DatatTemplate should display scrolbar if content exceeds than max limit

978 views Asked by At

I have a datatemplate in my radGridviewDataColumn, what i wanted to achieve is.

  1. if the text of the textblock exceeds the size of the available grid view cell then verticle scrollbar should display.

  2. if user tries click on the templated column then the row should be selected(currently i am not able to select the row when clicking on templated column, if click on other column then row is getting selection.

Sample xaml:

<telerik:GridViewDataColumn UniqueName="UN" x:Name="IrColumn" Header="{Binding Path=Localization[ID71]}" TextAlignment="Right" Width="150" >
        <telerik:GridViewDataColumn.CellTemplate>
               <DataTemplate>
                      <ScrollViewer HorizontalScrollBarVisibility="Disabled"   VerticalScrollBarVisibility="Auto" HorizontalAlignment="Stretch"  >
                             <TextBlock x:Name="IrcIdentShortDescriptionColumnTextBox"
                                        TextWrapping ="Wrap"
                                        Text="Sampletext" 
                                        IsEnabled="False" />
                      </ScrollViewer>
               </DataTemplate>
        </telerik:GridViewDataColumn.CellTemplate>
</telerik:GridViewDataColumn>
1

There are 1 answers

3
dev hedgehog On BEST ANSWER

Try set a fix width value on your ScrollViewer just to test if the ScrollViewer will display the ScrollBars when TextBlock exceeds ScrollViewier's width value.

If you set fix width value and ScrollBars become visible because text exceeds the width limits then you are using wrong layout panel for your ScrollViewer. This is rather to happen and therefore you have this issue.

In order to fix this simply bind the ScrollViewer's width to column's width by using RelativeSource Binding.

Could you please set the fix width value and try it out.