This is the ContentTemplate for my XamDataGrid Field. No matter what I do, the cell height will not expand to accommodate the TextBlock. Please help. thanks
<Style x:Key="CellValuePresenterStyle" TargetType="{x:Type igDP:CellValuePresenter}">
<Setter Property="ContentTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Text="{Binding Comment}" DataContext="{Binding DataContext.DataItem, RelativeSource={RelativeSource AncestorType={x:Type igDP:CellValuePresenter}}}" TextWrapping="Wrap">
</TextBlock>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
Hello Guan,
Thank you for your post.
I have been looking into the sample application that you have provided. The assemblies used in it are for 12.2. I have tested the sample with the latest service release for 12.2 and I could not reproduce the issue, it seems that your sample works fine on my side. I attached a screenshot with the result. Can you provide me with the exact version, that you are using(volume and service release)?
Please let me know if there are some specific steps, that I can follow, in order to reproduce the issue.
Looking forward to hearing from you.
It seems that you uncomment the line TextWrapping property of the TextEditorStyle. The cell will size to the height of the build-in text editor just fine.
My problem is the third column which has a ContentTemplate. The cell will not size to the height of the TextBlock within the content template when it is wrapped.
Thanks
I have further researching your issue and the sample application that you have provided. It seems that the reason for it is because you are using ContentTemplate instead of Template. In order to achieve your requirement without using style for XamTextEditor, you should change the ContentTamplate with Template and DataTemplate with ControlTemplate.
Please let me know if you need any further assistance on this matter.
I would rather avoid the CtontrolTemplate if I could, because I will loose some built in cell functionalities. Is there a way to get this to work in the ContentTemplate instead?
I have been looking into it and it seems that I am missing something from your scenario. Would you please provide me with more detailed information what is the issue when you use the style for the XamTextEditor. Also would you please provide with more detailed description of your requirements in order to be able to investigate your issue.
The included example is a simplified scenario. I have to use a ContentTemplate because I need to include HyperLinks as well as commands in the cell. Therefore, the style for the XamTextEditor is not going to cut it.
Anyway, I figured it out. It seems that the cell will render correctly if I apply both cell editor style and the CellValuePresenter ContenTemplate in the following manner. I have attached the modified project as well.
<Window.Resources> <Style x:Key="TextEditorStyle" TargetType="{x:Type igEditor:XamTextEditor}"> <Setter Property="TextWrapping" Value="Wrap"/> </Style> <Style x:Key="CellValuePresenterStyle" TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <TextBlock DataContext="{Binding DataContext.DataItem, RelativeSource={RelativeSource AncestorType={x:Type igDP:CellValuePresenter}}}" TextWrapping="Wrap"> <Hyperlink Foreground="Red">Test</Hyperlink> <TextBlock Text="{Binding Comment}" TextWrapping="Wrap"/> </TextBlock> </DataTemplate> </Setter.Value> </Setter> </Style> </Window.Resources> <igDP:XamDataGrid DataSource="{Binding Tasks}"> <igDP:XamDataGrid.FieldLayoutSettings> <igDP:FieldLayoutSettings AutoGenerateFields="False"/> </igDP:XamDataGrid.FieldLayoutSettings> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:Field Name="TaskID"/> <igDP:Field Name="Name"> <igDP:Field.Settings> <igDP:FieldSettings EditorStyle="{StaticResource TextEditorStyle}" CellValuePresenterStyle="{StaticResource CellValuePresenterStyle}" CellContentAlignment="LabelAboveValueAlignLeft" AutoSizeOptions="All" AutoSizeScope="RecordsInView" AllowEdit="False" /> </igDP:Field.Settings> </igDP:Field> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> </igDP:XamDataGrid>
Thank you for your feedback.
I am very glad, that you achieve your requirements.