Tabchanged event on nested user control

3 posts, 0 answers
  1. Mark
    Mark avatar
    55 posts
    Member since:
    Dec 2010

    Posted 23 Mar Link to this post

    I have a Main form with a tab control where I am trapping the tab change event in the view model.

    <i:Interaction.Triggers>
                    <i:EventTrigger EventName="SelectionChanged">
                        <i:InvokeCommandAction Command="{Binding TabChanged}"
                                 CommandParameter="{Binding ElementName=TCMain}" />
                    </i:EventTrigger>
    </i:Interaction.Triggers>

    Note the element name

    In my view model I successfully trap the event for processing relying on the name to identify the tab control

    private void tabChanged(object o)
    {
        if (o == null) { return; }
        if (o.GetType() == typeof(Telerik.Windows.Controls.RadTabControl))
        {
            if ((o as Telerik.Windows.Controls.RadTabControl).Name != "TCMain")
            {
                return;
            }
        }
    }

    One of the main window tab items also has a user control which has a tab control called UCTab, it has no tabchanged event processing.

    When I change tabs on the UCTab the event on TCMain fires and the name passed to the event in the view model is the TCMain tab.

    Is it possible to isolate the UCTab from the event processing.

    (I have solved this by changing the UCTab to a standard MS tab control but it is very unsatisfactory).

    I have a sample project to demonstrate the problem if required.

     

     

     

     

     

     

     

  2. Nasko
    Admin
    Nasko avatar
    693 posts

    Posted 28 Mar Link to this post

    Hello Mark,

    What we could suggest you for your scenario is instead of using the EventTrigger to use our EventToCommandBehavior. Using it you will be able to pass the event arguments to the Command and thus to find out the TabControl that is invoking it.

    We have created a sample project that demonstrates the described above approach. Please, give it a try and let us know if it worked for you.

    Hope this helps.

    Regards,
    Nasko
    Telerik by Progress
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  3. Mark
    Mark avatar
    55 posts
    Member since:
    Dec 2010

    Posted 28 Mar in reply to Nasko Link to this post

    Thanks Nasko, will get back to you if I have any problems.
Back to Top