I've added a TemplateColumn to my grid row. The value of this cannot be bound as it needs to be evaluated at runtime.
I've added an event handler to the InitializeRow event of the grid and I've got the cell object using .Row.Cells("dynamicDescription"). Is there any way I can access the TextBlock control within the template column and set it's value?
Many thanks.
Hi,
Sorry if i was unclear in my previous post, but with the UnboundColumn, the DataContext is different from the DataContext of a TemplateColumn. Instead, we offer more properties so users can have more options of what to bind to.
So, you can't binding directly to your data without specifying a Path anymore. Instead, if you want to bind directly to your data, you need
{Binding RowData} instead of {Binding}
and if you want to bind to a specific property in your data, you need:
{Binding RowData.PropertyName} instead of {Binding PropertyName}
Hope this helps clarify things.
-SteveZ
I am trying to use a converter in Unbound column ,specifying the data context property and using converter.the data template is as follows
<DataTemplate x:Key="deleteButtonColumnTemplate"> <Grid> <Button Tag="{Binding}" DataContext="{Binding}" Content="Delete" Click="deleteButton_Click" x:Name="deleteButton" IsEnabled="{Binding data_source , Converter=disableDeleteButton}"/> </Grid>
Note:data_source is a column in Grid and is also present in datasource object.
The column does not call the converter even after using DataContext.
I cannot access the unbound cel-button in events RowInitilize and ControlAttached.The cell's Control.Content property returns null in these events
The UnboundColumn's DataContext is of type UnboundColumnDataContext which contains the following properties:RowData, Value and ColumnKey.
So you definitely should still be able to user a converter as you have the data of the row in which the cell belongs to.
What happens in case of Unbound columns?
How can I access the Unboundcell and change the control(Button) inside it to enable/disable?
I cannot do this at design time..have to decide it dynamically.Cannot use converter as Unbound columns are not bound to the datasource.
Thanks
That worked - many thanks Darrell!