Is it possible to set the text of a Textbox in code behind of a unbounded TemplateField ?
Hello Stephane,
For styling the XamDataGrid please refer to our online documentation and styling points. For marking an empty text with a red border you can do something like this with a trigger.
eg.
<Style TargetType="{x:Type ig:DataRecordCellArea}"> <Style.Triggers> <DataTrigger Value=""> <Setter Property="BorderBrush" Value="Red"/> <Setter Property="BorderHoverBrush" Value="Red"/> <Setter Property="BorderActiveBrush" Value="Red"/> <Setter Property="BorderSelectedBrush" Value="Red"/> <Setter Property="BorderThickness" Value="2"/> </DataTrigger> </Style.Triggers></Style>
With a unbounded TextField i can display my calculated value, but we want to keep a similar appearance between all the columns and allow the copy / paste of text, that's why we try to use the TextBox in a TemplateField (unbound). In addition we would like to put the red border when the text is empty ...
Is there a specific reason you are using a TemplateField and not an Unbound field? The following topic demonstrates how to wire up Fields with BindingType set as Unbound to present calculated data
https://ko.infragistics.com/help/wpf/xamcalculationmanager-using-xamcalculationmanager-with-xamdatagrid
Let me know if this is more inline with what you are trying to achieve.
igEditors:TemplateEditor.Editor don't exist (Editor) and the textbox is readonly just for display a calculated information, i'm not in edition... in our case the xamDataGrid is used to display only our data. We have a column with a button to edit the current row in a new independant window (complex need). So all Template fields have a textbox binded to data, except 2 Template Fields with textbox that are calculated and i need to feed this textbox with a calculated data in code behind. Does it simply possible ? a textbox in a TemplateField cannot be accessed anywhere ?
I don't see any binding on the your Textbox for the TemplateField so you would just have to add that. <TextBlock Text="{Binding Path=(igEditors:TemplateEditor.Editor).Value, RelativeSource={RelativeSource Self}}"Use the TemplateEditorValueBinding markup extension to facilitate the binding to the underlying data.
TemplateEditorValueBinding