P
P
prikazchikof2016-05-26 00:10:40
WPF
prikazchikof, 2016-05-26 00:10:40

How to open UserControl via TabControl?

There is a TabControl:

<Controls:MetroAnimatedSingleRowTabControl x:Name="MainTabControl" Grid.Row="1">
            <TabItem Header="buttons">
                <exampleViews:ButtonsExample DataContext="{Binding}" />
            </TabItem>
            <TabItem Header="text">
                <exampleViews:TextExamples DataContext="{Binding}" />
            </TabItem>

And there is a UserControl:
<UserControl x:Class="MetroDemo.ExampleViews.ButtonsExample"
         xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
         xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
         xmlns:Controls="http://metro.mahapps.com/winfx/xaml/controls"
         xmlns:MetroDemo="clr-namespace:MetroDemo"
         xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
         xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
         mc:Ignorable="d"
         d:DesignHeight="737.288"
         d:DesignWidth="800"
         d:DataContext="{d:DesignInstance MetroDemo:MainWindowViewModel}">

When a specific TabItem is clicked, it opens the required UserControl on the window. How is this mechanism implemented? PS The code is taken from the MahApps repository https://github.com/MahApps/MahApps.M...ples/MetroDemo

Answer the question

In order to leave comments, you need to log in

1 answer(s)
#
#algooptimize #bottize, 2016-05-26
@user004

No time to study the theory yourself?)

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question