This is a migrated thread and some comments may be shown as answers.

DataForm DataFormComboBoxField SelectionChange Handler

3 Answers 173 Views
DataForm
This is a migrated thread and some comments may be shown as answers.
Gencebay
Top achievements
Rank 1
Gencebay asked on 16 Nov 2014, 08:31 AM
Hi,
I compined DataForm and PropertyGrid controls properly but I want to do that handle DataFormComboBoxField change event and as configured DataTemplate like that.

<
telerik:RadDataForm Grid.Row="0" x:Name="DataForm1"
                             Header="Actor Basic"
                            AutoGenerateFields="False"
                            ItemsSource="{Binding MyDTO}"
                            ReadOnlyTemplate="{StaticResource MyTemplate}"
                            EditTemplate="{StaticResource MyTemplate}"
                            NewItemTemplate="{StaticResource MyTemplate}"
                            EditEnded="DataForm1_EditEnded" >
<
DataTemplate x:Key="MyTemplate">
                <StackPanel>
                    <telerik:DataFormDataField  Label="İsim" DataMemberBinding="{Binding Name, Mode=TwoWay}" />
                    <telerik:DataFormComboBoxField Label="Some Label" SelectedValuePath="ID" DisplayMemberPath="TypeName"
                                DataMemberBinding="{Binding AnotherId, Mode=TwoWay}"
                                ItemsSource="{Binding RelativeSource={RelativeSource FindAncestor,
                                AncestorType={x:Type UserControl}}, Path=DataContext.SomeList}" />
                </StackPanel>
            </DataTemplate>

3 Answers, 1 is accepted

Sort by
0
Boris
Telerik team
answered on 19 Nov 2014, 10:47 AM
Hello Gencebay,DataFormComboBoxField does not have a SelectionChanged event itself. In case you need such an event to implement your additional logic, you can handle the SelectionChanged event of its editing element (RadComboBox). For example the code to do so is available bellow:

public MainWindow()
    {
        InitializeComponent();
        this.AddHandler(RadComboBox.SelectionChangedEvent, new System.Windows.Controls.SelectionChangedEventHandler(OnSelectionChanged));
    }
 
    private void OnSelectionChanged(object sender, SelectionChangedEventArgs e)
    {
        if (e.RemovedItems.Count > 0)
        {
            //your code here
        }
    }

You can see that with the code snippet above I check if there are any items being unselected (through the bt). This ensures that the event will not be handled on the initial loading when a default item has been selected.

I hope this helps.

Regards,
Boris
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
0
Gencebay
Top achievements
Rank 1
answered on 24 Dec 2014, 08:30 AM
Hello,
Trying add to the RadDataForm a DataTemplateSelector for each template type (Read, Edit etc.) on runtime for specified type to edit!
There is only one EditTemplateSelector for RadDataForm how can we bind right template dynamically?
Thanks
0
Dimitrina
Telerik team
answered on 25 Dec 2014, 09:37 AM
Hello,

You can refer to our online documentation on DataTemplate Selectors.

Regards,
Dimitrina
Telerik
 

Check out the Telerik Platform - the only platform that combines a rich set of UI tools with powerful cloud services to develop web, hybrid and native mobile apps.

 
Tags
DataForm
Asked by
Gencebay
Top achievements
Rank 1
Answers by
Boris
Telerik team
Gencebay
Top achievements
Rank 1
Dimitrina
Telerik team
Share this question
or