Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

TabControl loose on switch

$
0
0

hi,

i have a TabControl bound to an ObservableCollection like so

<TabControl x:Name="examenstabcontrol"
                    ContentTemplateSelector="{DynamicResource ExamenTemplateSelector}"
                    ItemsSource="{Binding EXAMENS}"></TabControl>


please note that i am setting the content of the tabs with a DataTemplateSelector

   public class ExamenTemplateSelector : DataTemplateSelector
    {
        public override DataTemplate SelectTemplate(object item, DependencyObject container)
        {


            EXAMEN ex = item as EXAMEN;

            FrameworkElement win = container as FrameworkElement;

            switch (ex.EXAMENS_TYPES.ID_EXAMEN_TYPE)
            {
                case 7:
                    return win.FindResource("ECGtemplate") as DataTemplate;

                case 8:
                    return win.FindResource("Echocoeurtemplate") as DataTemplate;
                case 12:
                    return win.FindResource("ExamenCliniquetemplate") as DataTemplate;
                      case 13:
                    return win.FindResource("Echographie2Dtemplate") as DataTemplate;


                default:
                    return win.FindResource("Arterestemplate") as DataTemplate;

            }
        }

    }

the various datatemplates are mainly usercontrols with some input controls .

i have some buttons that add items to the ObservableCollection and it initially works

the problem is that if i switch between tabs all the respective modifications are lost like if the tab switched on is newly created

any idea is welcome .

thanks and good day .


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>