Hi,
What I am trying to achieve is this: Depending what I am bound to, the cell in edit mode will display different types of controls i.e a checkbox, combobox, TextBox etc.. Looking at the ControlTemplate named 'EditTemplate', below, is incorrect because you cannot have a DataTemplate as a child of a border. In the Microsoft data grid world you have something called a CellEditingTemplate, where a DataTemplate is permissible. I see in your grid you have something named a CellEditTemplate, but, alas, I could not find any examples/documentation to view this object.
so....
1. Am I correct to use a style (named UDFCellViewStyle) with a trigger to determine if the grid is in edit mode
2. Can I use the CellEditTemplate instead of a style trigger
3. How can I use my datatemplate for your cell in Edit mode
Thanks
P
What I am trying to achieve is this: Depending what I am bound to, the cell in edit mode will display different types of controls i.e a checkbox, combobox, TextBox etc.. Looking at the ControlTemplate named 'EditTemplate', below, is incorrect because you cannot have a DataTemplate as a child of a border. In the Microsoft data grid world you have something called a CellEditingTemplate, where a DataTemplate is permissible. I see in your grid you have something named a CellEditTemplate, but, alas, I could not find any examples/documentation to view this object.
so....
1. Am I correct to use a style (named UDFCellViewStyle) with a trigger to determine if the grid is in edit mode
2. Can I use the CellEditTemplate instead of a style trigger
3. How can I use my datatemplate for your cell in Edit mode
<LocalFramework:UDFValueConverter x:Key="UDFValueConverter" /> |
<Style x:Key="ComboStyleUDFMultipleSelect" TargetType="{x:Type ComboBox}"> |
<Setter Property="ItemTemplate"> |
<Setter.Value> |
<DataTemplate> |
<StackPanel Orientation="Horizontal"> |
<CheckBox x:Name="chkSelected" HorizontalContentAlignment="Center" VerticalContentAlignment="Center"/> |
<TextBlock Text="{Binding Path=Value}" TextWrapping="Wrap" x:Name="txtListValue" Margin="2,0,0,0"/> |
</StackPanel> |
</DataTemplate> |
</Setter.Value> |
</Setter> |
</Style> |
<ControlTemplate x:Key="NormalTemplate" TargetType="telerikGridView:GridViewCell"> |
<Border BorderThickness="{TemplateBinding BorderThickness}" |
BorderBrush="{TemplateBinding BorderBrush}" |
Background="LightGreen" > |
<TextBlock Text="{Binding Converter={StaticResource UDFValueConverter}}" ToolTip="{Binding RelativeSource={RelativeSource Self}, Path=Text}" /> |
</Border> |
</ControlTemplate> |
<ControlTemplate x:Key="EditTemplate" TargetType="telerikGridView:GridViewCell"> |
<Border BorderThickness="{TemplateBinding BorderThickness}" |
BorderBrush="{TemplateBinding BorderBrush}" |
Background="{TemplateBinding Background}"> |
<DataTemplate> |
<StackPanel x:Name="sp_Value" Orientation="Vertical" > |
<toolkit:DatePicker x:Name="dpValue" Visibility="Collapsed" SelectedDateFormat="Short" /> |
<TextBox x:Name="txtValue" Visibility="Collapsed" /> |
<ComboBox x:Name="cboValue" Visibility="Collapsed" DisplayMemberPath="Value" SelectedItem="{Binding CityInfo, Mode=TwoWay}" ItemsSource="{Binding UDFListValues, Source={StaticResource CMXLookUPsDS}}"></ComboBox> |
<CheckBox x:Name="chkValue" Visibility="Collapsed"></CheckBox> |
</StackPanel> |
<DataTemplate.Triggers> |
<DataTrigger Binding="{Binding Path=UDF.UDFDataType.Name}" Value="System.String"> |
<Setter TargetName="txtValue" Property="Visibility" Value="Visible"></Setter> |
</DataTrigger> |
<MultiDataTrigger> |
<MultiDataTrigger.Conditions> |
<Condition Binding="{Binding Path=UDF.UDFDataType.Name}" Value="System.Collections.ArrayList" /> |
<Condition Binding="{Binding Path=UDF.MultpleSelect}" Value="true" /> |
</MultiDataTrigger.Conditions> |
<Setter TargetName="cboValue" Property="Visibility" Value="Visible" /> |
<Setter TargetName="cboValue" Property="Style" Value="{StaticResource ComboStyleUDFMultipleSelect}" /> |
</MultiDataTrigger> |
<MultiDataTrigger> |
<MultiDataTrigger.Conditions> |
<Condition Binding="{Binding Path=UDF.UDFDataType.Name}" Value="System.Collections.ArrayList" /> |
<Condition Binding="{Binding Path=UDF.MultpleSelect}" Value="false" /> |
</MultiDataTrigger.Conditions> |
<Setter TargetName="cboValue" Property="Visibility" Value="Visible"></Setter> |
</MultiDataTrigger> |
<DataTrigger Binding="{Binding Path=UDF.UDFDataType.Name}" Value="System.Boolean"> |
<Setter TargetName="chkValue" Property="Visibility" Value="Visible"></Setter> |
</DataTrigger> |
<DataTrigger Binding="{Binding Path=UDF.UDFDataType.Name}" Value="System.DateTime"> |
<Setter TargetName="dpValue" Property="Visibility" Value="Visible"></Setter> |
</DataTrigger> |
</DataTemplate.Triggers> |
</DataTemplate> |
</Border> |
</ControlTemplate>
<Style x:Key="UDFCellViewStyle" TargetType="telerikGridView:GridViewCell">
<Style.Triggers>
<Trigger Value="False" Property="IsInEditMode">
<Setter Property="telerik:GridViewCell.Template" Value="{StaticResource NormalTemplate}"/>
</Trigger>
<Trigger Value="True" Property="IsInEditMode">
<Setter Property="telerik:GridViewCell.Template" Value="{StaticResource EditTemplate}"/>
</Trigger>
</Style.Triggers>
</Style>
|
Thanks
P