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

Tabchanged event on nested user control

2 Answers 429 Views
TabControl
This is a migrated thread and some comments may be shown as answers.
Mark
Top achievements
Rank 1
Mark asked on 24 Mar 2017, 02:05 AM

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 Answers, 1 is accepted

Sort by
0
Nasko
Telerik team
answered on 28 Mar 2017, 06:46 AM
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.
0
Mark
Top achievements
Rank 1
answered on 28 Mar 2017, 07:22 AM
Thanks Nasko, will get back to you if I have any problems.
Tags
TabControl
Asked by
Mark
Top achievements
Rank 1
Answers by
Nasko
Telerik team
Mark
Top achievements
Rank 1
Share this question
or