simsenVejle
Well-known member
- Joined
- Feb 14, 2021
- Messages
- 46
- Programming Experience
- Beginner
Hi
I have the following TabControl with TabItems. I need to make som code when the Selection changes to another tab.
First time I run the app I am going into the SelectionChanged. But then when choosing a new tab nothing happens at all. I want to go into the code each time, I hit the tabs. What do I have to do to get that?
Best regards
SImsen
I have the following TabControl with TabItems. I need to make som code when the Selection changes to another tab.
First time I run the app I am going into the SelectionChanged. But then when choosing a new tab nothing happens at all. I want to go into the code each time, I hit the tabs. What do I have to do to get that?
TabControl:
<TabControl x:Name="tabAccountView" Style="{StaticResource tabControlLarge}" SelectionChanged="tabAccountView_OnSelectionChanged">
<TabItem Name="tabPlatform" Header="Platform" Style="{StaticResource tabItemLarge}">
<local:AccountPlatformView x:Name="AccountPlatformView" />
</TabItem>
<TabItem Name="tabEnvironment" Header="Miljø" Style="{StaticResource tabItemLarge}">
<local:AccountEnvironmentView x:Name="AccountEnvironmentView" />
</TabItem>
<TabItem Name="tabEnvironmentVersion" Header="Miljø Version" Style="{StaticResource tabItemLarge}">
<local:AccountEnvironmentVersionView x:Name="AccountEnvironmentVersionView" />
</TabItem>
<TabItem Name="tabComponent" Header="Komponent" Style="{StaticResource tabItemLarge}">
<local:AccountComponentView x:Name="AccountComponentView" />
</TabItem>
<TabItem Name="tabPriority" Header="Prioritet" Style="{StaticResource tabItemLarge}">
<local:AccountPriorityView x:Name="AccountPriorityView" />
</TabItem>
<TabItem Name="tabSeverity" Header="Sværhedsgrad" Style="{StaticResource tabItemLarge}">
<local:AccountSeverityView x:Name="AccountSeverityView" />
</TabItem>
<TabItem Name="tabStatus" Header="Status" Style="{StaticResource tabItemLarge}">
<local:AccountStatusView x:Name="AccountStatusView" />
</TabItem>
<TabItem Name="tabCategory" Header="Kategori" Style="{StaticResource tabItemLarge}">
<local:AccountCategoryView x:Name="AccountCategoryView" />
</TabItem>
</TabControl>
Codebehind code:
private void tabAccountView_OnSelectionChanged(object sender, SelectionChangedEventArgs e)
{
//test 1
if (e.Source is TabControl)
{
//test 2
if (tabEnvironmentVersion.IsSelected)
{
//test 3
//Hente viewModel og opdater Environments
EnvironmentVersionViewModel vm = new EnvironmentVersionViewModel();
vm.Update();
}
}
}
SImsen
Last edited by a moderator: