Hi,
I have a XamGrid with 3 columns.
Last column is an unbound column.
I would like to bind TextBlock in this column to same value as one of the TextColumn.
This is the code :
-----------------------------------------------------
<ig:XamGrid x:Name="MyElements" ItemsSource="{Binding Elements}" ActiveItem="{Binding OneElement, Mode=TwoWay}" > <ig:XamGrid.Columns> <ig:TextColumn Key="UserName" HeaderText="User name" ></ig:TextColumn> <ig:TextColumn Key="Points" HeaderText="Points" ></ig:TextColumn> <ig:UnboundColumn Key="calculated" HeaderText="With coeff." > <ig:UnboundColumn.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding [HERE I WANT TO BIND TO Points], RelativeSource={RelativeSource AncestorType=ig:XamGrid}}"></TextBlock> </DataTemplate> </ig:UnboundColumn.ItemTemplate> </ig:UnboundColumn> </ig:XamGrid.Columns></ig:XamGrid>
------------------------------
First of all, I want to display the same data in 2nd and 3rd data.
Because after that I will use a converter to transform text in 3rd column.(remark : convertion will use some data not present in "OneElement")
Do you know if this is possible to bind the TextBlock content to the TextColumn value ?
Thanks.
Alain.
Hi Georgi,
This is what I was looking for.
It works.
Thanks for your help.
Hello Alai,
I am just checking if you require any further assistance on the matter.
Sincerely,
Krasimir
Developer Support Engineer
Infragistics
www.infragistics.com/support
Hello Alain,
I have been reading through your post and the DataContext of the TextBlock that you wish to bind to the same data as the TextColumn is a UnboundColumnDataContext. This class exposes a DataRow property which represents the object that corresponds to the current Row. You can use the DataRow property in order to get the value of the property that corresponds to the Points column. I have created a sample application for you, which demonstrates how you can use the UnboundColumnDataContext in order to achieve the functionality that you have described.
Please let me know if you need any further assistance on the matter.
Hi Alain,
In the DataContext of the UnboundColumn, there's a RowData property pointing to your data object.
So, your column should look something like this:
<ig:UnboundColumn Key="calculated" HeaderText="With coeff." > <ig:UnboundColumn.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding RowData.Points}" /> </DataTemplate> </ig:UnboundColumn.ItemTemplate> </ig:UnboundColumn>
Hope this helps,