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 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,
Hi Georgi,
This is what I was looking for.
It works.
Thanks for your help.