here are two ways I implement the wrap text for the cell.
I have button and when I click the button the warp text style will be applied to the cells.
However, both two ways have a weak point.
after impement it as Way1, all the cells are editable although I handle the StartEditing event.
after impement it as Way2, I first decrease the row height until the text is cut and then apply the wrap text style, the text is cu.
Could you please tell me how to fix this?
Way1:
<igDP:XamDataGrid>
<igDP:XamDataGrid.Resources> <Style TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <igEditors:XamTextEditor Margin="{TemplateBinding Padding}" Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" VerticalScrollBarVisibility="Auto" Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Content}" TextWrapping="Wrap" Background="Transparent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/> </ControlTemplate> </Setter.Value> </Setter> </Style>
Way2:
<Style TargetType="{x:Type igDP:XamTextEditor }"><Setter Property="TextWrapping" Value="Wrap"/>
<Setter Property=“HorizontalAlignment Value="Stretch"/><Setter Proerty="VerticalAlignment" value="Stretch"/>
</Style></igDP:XamDataGrid.Resources>
</igDP:XamDataGrid>
In way2, I want the height of the XamTextEditor changed with the CellValuePresenter, althougth I add one setter like this(maybe the format is not correct in this reply), it still doesn't work:
<Setter Property="Height" Value="{Binding Path=ActualHeight, RelativeSource={RelativeSource FindAncester, Type={x;Type CellValuePresenter}}}"/>
Hello,
It has been a while since you have made your post, in case you still need support I will be glad to assist you further. I suppose the other community members can benefit from this answer as well. I have been looking into your post and I can suggest you use the following Style instead of the one you used in “way1”:
<Style TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <igEditors:XamTextEditor Margin="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:CellValuePresenter}}, Path=Padding}" Width="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:CellValuePresenter}}, Path=Width}" Height="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:CellValuePresenter}}, Path=Height}" VerticalScrollBarVisibility="Auto" Text="{Binding RelativeSource={RelativeSource AncestorType={x:Type igDP:CellValuePresenter}}, Path=Content}" TextWrapping="Wrap" Background="Transparent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"/> </DataTemplate> </Setter.Value> </Setter> </Style>
Feel free to write me if you have further questions.