Hi,
I am trying out the Infragistics WPF controls (version 9.1) and am facing a little problem. In my XamDataGrid, I want to use a Field that holds a TextBlock and that TextBlock's Text property needs to be bound to a property which is being used as the DataSource of the XamDataGrid. Here's the code-
<igDP:XamDataGrid x:Name="xdgAuditGrid" Theme="Office2k7Black" BorderBrush="Silver" BorderThickness="6" Padding="10"> <igDP:XamDataGrid.FieldLayouts> <igDP:FieldLayout> <igDP:FieldLayout.Settings> <igDP:FieldLayoutSettings AutoGenerateFields="False" AllowAddNew="False" AllowDelete="False"/> </igDP:FieldLayout.Settings> <igDP:FieldLayout.Fields> <igDP:Field x:Name="dgcRevisionStamp" Name="RevisionStamp" Label="Occured On" /> <igDP:Field x:Name="dgcAction" Name="Actions" Label="Action" Converter="{StaticResource ActionConverter}"/> <igDP:Field x:Name="dgcUserName" Name="UserName" Label="User Name" /> <igDP:Field x:Name="dgcTableName" Name="TableName" Label="Table Name" /> <igDP:UnboundField x:Name="dgcInitData" Label="Initial Data"> <igDP:Field.Settings> <igDP:FieldSettings> <igDP:FieldSettings.CellValuePresenterStyle> <Style TargetType="{x:Type igDP:CellValuePresenter}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type igDP:CellValuePresenter}"> <TextBlock x:Name="txbOldData" Text="{Binding OldData}" Loaded="TxbOldData_Loaded" ToolTipService.ShowDuration="20000"/> </ControlTemplate> </Setter.Value> </Setter> </Style> </igDP:FieldSettings.CellValuePresenterStyle> </igDP:FieldSettings> </igDP:Field.Settings> </igDP:UnboundField> </igDP:FieldLayout.Fields> </igDP:FieldLayout> </igDP:XamDataGrid.FieldLayouts> <igDP:XamDataGrid.FieldSettings> <igDP:FieldSettings AllowEdit="False"/> </igDP:XamDataGrid.FieldSettings> </igDP:XamDataGrid>
The code marked in bold, should bind the text property of the control "txbOldData". But after the datagrid is loaded, all other properties are bound, except for the "Initial Data" column.
It'd be of great help if you could show me what I am doing wrong here?
Thanks a bunch!!
Hello,
You should not retemplate the CellValuePresenter. If you want to bind to a property, you should use the BindingPath property of the Unbound Field
<UnboundField ... BindingPath="oldData"...
Thanks a lot for the quick reply. But I need that TextBlock to be bound to the "OldData" so that in the TextBlock's Loaded event I can add a ToolTip to that TextBlock. This is required to present the data in property "OldData" in a different way.
Basically, "OldData" is a string that has values read from an xml file. I need to show the values from that xml file in the tooltip so that it is well understood by the end-user.
So, what do I have to do, if I have to retemplate the cell with a textblock and bind the text property of that textblock? And, I know I'm asking for a lot, but is there any other way I can achieve this?
Thanks again for your support....
The ContentPresenter (inside the CellValuePresenter) is bound to what you set in the BindingPath property. So, if you set the BindingPath property to OldData, you do not have to retemplate it. As you want to set the tooltip, you can use the CellValuePresenter Loaded event, or InitializeRecord event and set this tooltip there.
If you really need to retemplate the CellValuePresenter, you should again set the BindingPath property and set a binding to the TextBlock, with Path=Content and RelativeSource to TemplatedParent as bmos has proposed.
Another option that you have is to use a Converter (IValueConverter apply at the content property of the CellValuePresenter) and use it to set the value, as well as the ToolTip at the same time.
Thanks a LOT for you support!!
I am back :)
I have retemplated the unboundfield and used Path=Content and RelativeSource. The data is binding but the Filters don't seem to work on this Grid. When I turn the filtering ON, the grid fails to load and the entire app freezes. The other XamDataGrids in my projects renders fine (none of them has UnboundFields or retemplated styles, though).
What might be the problem?
Thanks
This looks like an issue. I can reproduce it as well.
I am going to create a support case on your behalf so that we can continue the discussion there.
Thanks a lot :D