Hi,
I'm trying to use the DataGridView control with a DataTemplate. This bit seems ok at the moment.
I am planning on using a convertor to automatically select the CellStyle based on the value of the column. I expect this shouldn't be too tricky.
What I am having problems with is trying to bind the content of the control to another cell's value. Or using another cells value for a property.
Any help/examples would be greatly appreciated.
Eg
Record
======
Name = "My Textbox"
Control = "Textbox"
Default = "This is my default value"
The Control Column will become a TextBox and I would like the TextBox Value to become the value of the Default,
I have tried things like
Text="{Binding Default}"
Text="{Binding Path=Default, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:GridViewRow}}}"
I'm trying to use the DataGridView control with a DataTemplate. This bit seems ok at the moment.
I am planning on using a convertor to automatically select the CellStyle based on the value of the column. I expect this shouldn't be too tricky.
What I am having problems with is trying to bind the content of the control to another cell's value. Or using another cells value for a property.
Any help/examples would be greatly appreciated.
Eg
Record
======
Name = "My Textbox"
Control = "Textbox"
Default = "This is my default value"
The Control Column will become a TextBox and I would like the TextBox Value to become the value of the Default,
I have tried things like
Text="{Binding Default}"
Text="{Binding Path=Default, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type telerik:GridViewRow}}}"
<UserControl x:Class="WizardAdvanced" |
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" |
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"> |
<Grid> |
<Grid.Resources> |
<Style x:Key="CheckboxCellStyle" TargetType="{x:Type telerik:GridViewCell}"> |
<Setter Property="ContentTemplate"> |
<Setter.Value> |
<DataTemplate> |
<CheckBox VerticalAlignment="Center" /> |
</DataTemplate> |
</Setter.Value> |
</Setter> |
</Style> |
<Style x:Key="TextboxCellStyle" TargetType="{x:Type telerik:GridViewCell}"> |
<Setter Property="ContentTemplate"> |
<Setter.Value> |
<DataTemplate> |
<TextBox Text="{Binding Default}" /> |
</DataTemplate> |
</Setter.Value> |
</Setter> |
</Style> |
<Style x:Key="ListboxCellStyle" TargetType="{x:Type telerik:GridViewCell}"> |
<Setter Property="ContentTemplate"> |
<Setter.Value> |
<DataTemplate> |
<ComboBox HorizontalAlignment="Left" VerticalAlignment="Bottom"/> |
</DataTemplate> |
</Setter.Value> |
</Setter> |
</Style> |
</Grid.Resources> |
<telerik:RadGridView Margin="0" Name="Grid" AutoGenerateColumns="False"> |
<telerik:RadGridView.Columns> |
<telerik:GridViewDataColumn Header="Name" DataMemberBinding="{Binding Name}"></telerik:GridViewDataColumn> |
<telerik:GridViewDataColumn Header="Control" DataMemberBinding="{Binding Control}" CellStyle="{StaticResource TextboxCellStyle}"></telerik:GridViewDataColumn> |
<telerik:GridViewDataColumn Header="Default" DataMemberBinding="{Binding Default}"></telerik:GridViewDataColumn> |
</telerik:RadGridView.Columns> |
</telerik:RadGridView> |
</Grid> |
</UserControl> |