DataForm DataFormComboBoxField SelectionChange Handler

4 posts, 0 answers
  1. Gencebay
    Gencebay avatar
    3 posts
    Member since:
    Sep 2014

    Posted 16 Nov 2014 Link to this post

    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>
  2. Boris
    Admin
    Boris avatar
    276 posts

    Posted 19 Nov 2014 Link to this post

    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.

     
  3. UI for WPF is Visual Studio 2017 Ready
  4. Gencebay
    Gencebay avatar
    3 posts
    Member since:
    Sep 2014

    Posted 24 Dec 2014 in reply to Boris Link to this post

    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
  5. Dimitrina
    Admin
    Dimitrina avatar
    3769 posts

    Posted 25 Dec 2014 Link to this post

    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.

     
Back to Top