0

I have a custom control. In custom control i have used tab control to display the some list items. In tab control i have 3 tab items. If i click first tab item some operation will happen. i have treeview structure in second tab. If i expand the treeview the tree view is not expanded instead of that i was navigated to first tab. I have used interaction event trigger for selectionchanged event. but i faced the problem. I hope i will get solution or some idea after post this.

Hi, if i use other than tree view inside the tabitem i faced the same error. I think i done mistake in xaml part. Please find the xaml part of my code,

<i:Interaction.Triggers>
    <i:EventTrigger EventName="SelectionChanged">
        <action:TabSelectionAction TargetObject="{Binding ElementName=DataTabName}" />
    </i:EventTrigger>
</i:Interaction.Triggers>

In this DataTabName is the name of the tab control. I have tried with CustomControlName as TargetObject if i used this i have faced "Target = 'Target' threw an exception of type 'System.InvalidOperationException'"exception so i have set the tabcontrol name as targetobject.

My action class like this: (I have used this action class at the time of getting exception)

internal class TabSelectionAction : TargetedTriggerAction<ClassNameofCustomControl>
{
    protected override void Invoke(object parameter)
    {
        if ((parameter as SelectionChangedEventArgs).OriginalSource is TabControl)
        {

Thanks in advance.

Regards, Devi

Stefan
  • 17,448
  • 11
  • 60
  • 79
Devi S
  • 19
  • 3
  • Hi, can you post some relevant parts of your code? The xaml and viewmodel in particular? – Stefan Jun 20 '17 at 10:46
  • Hi, if i use other than tree view inside the tabitem i faced the same error. I think i done mistake in xaml part. Please find the xaml part of my code, – Devi S Jun 20 '17 at 18:25
  • I still don't see any code or xaml. – Stefan Jun 20 '17 at 18:37
  • I have edited my question please see above edited question. – Devi S Jun 20 '17 at 18:40
  • Possible duplicate of [In C# WPF, why is my TabControl's SelectionChanged event firing too often?](https://stackoverflow.com/questions/3659858/in-c-sharp-wpf-why-is-my-tabcontrols-selectionchanged-event-firing-too-often) – grek40 Jun 20 '17 at 18:54
  • The shown code/xaml is still just an laughable incomplete fraction of nearly nothing. Are you even respecting the result of `if ((parameter as SelectionChangedEventArgs).OriginalSource is TabControl)` in your action? – grek40 Jun 20 '17 at 19:01
  • Hi Grek thanks for your valuable comments. In the action class I have perform some actions using background worker. I think the problem is because of this. I have tried with list view instead of tree view the same things happens(if I click any items inside the second tabitem the tab control selection changed was called) is there any way to unhook the tab control selection changed event in the run worker complete ... Thanks in advance – Devi S Jun 22 '17 at 06:07

0 Answers0