| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111 |
- <UserControl
- xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
- x:Class="ControlCatalog.Pages.TabControlPage"
- xmlns="https://github.com/avaloniaui"
- xmlns:viewModels="using:ControlCatalog.ViewModels"
- x:DataType="viewModels:TabControlPageViewModel">
- <DockPanel Classes.WithContentTemplates="{Binding IsChecked, ElementName=UseContentTemplates}">
- <DockPanel.Styles>
- <Style Selector="DockPanel.WithContentTemplates">
- <Style Selector="^ TabItem">
- <Setter Property="ContentTemplate">
- <DataTemplate x:CompileBindings="False">
- <Border BorderBrush="Red" BorderThickness="10">
- <ContentPresenter Content="{Binding}"/>
- </Border>
- </DataTemplate>
- </Setter>
- </Style>
- <Style Selector="^ TabControl">
- <Setter Property="ContentTemplate">
- <DataTemplate>
- <TextBlock Text="This template should be overriden by each TabItem's template."/>
- </DataTemplate>
- </Setter>
- </Style>
- </Style>
- </DockPanel.Styles>
- <TextBlock
- DockPanel.Dock="Top"
- Classes="h2"
- Text="A tab control that displays a tab strip along with the content of the selected tab"
- Margin="4">
- </TextBlock>
- <Grid
- ColumnDefinitions="*,*"
- RowDefinitions="*,100">
- <DockPanel
- Grid.Column="0"
- Margin="4">
- <TextBlock
- DockPanel.Dock="Top"
- Classes="h1"
- Text="From Inline TabItems">
- </TextBlock>
- <TabControl
- Margin="0 16"
- TabStripPlacement="{Binding TabPlacement}">
- <TabItem Header="_Arch">
- <StackPanel Orientation="Vertical" Spacing="8">
- <TextBlock>This is the first page in the TabControl.</TextBlock>
- <Image Source="/Assets/delicate-arch-896885_640.jpg" Width="300"/>
- </StackPanel>
- </TabItem>
- <TabItem Header="_Leaf">
- <StackPanel Orientation="Vertical" Spacing="8">
- <TextBlock>This is the second page in the TabControl.</TextBlock>
- <Image Source="/Assets/maple-leaf-888807_640.jpg" Width="300"/>
- </StackPanel>
- </TabItem>
- <TabItem Header="_Disabled" IsEnabled="False">
- <TextBlock>You should not see this.</TextBlock>
- </TabItem>
- </TabControl>
- </DockPanel>
- <DockPanel
- Grid.Column="1"
- Margin="4">
- <TextBlock
- DockPanel.Dock="Top"
- Classes="h1"
- Text="From DataTemplate">
- </TextBlock>
- <TabControl
- ItemsSource="{Binding Tabs}"
- Margin="0 16"
- DisplayMemberBinding="{Binding Header, x:DataType=viewModels:TabControlPageViewModelItem}"
- TabStripPlacement="{Binding TabPlacement}">
- <TabControl.DataTemplates>
- <DataTemplate x:DataType="viewModels:TabControlPageViewModelItem">
- <StackPanel Orientation="Vertical" Spacing="8">
- <TextBlock Text="{Binding Text}"/>
- <Image Source="{Binding Image}" Width="300"/>
- </StackPanel>
- </DataTemplate>
- </TabControl.DataTemplates>
- <TabControl.Styles>
- <Style Selector="TabItem" x:DataType="viewModels:TabControlPageViewModelItem">
- <Setter Property="IsEnabled" Value="{Binding IsEnabled}"/>
- </Style>
- </TabControl.Styles>
- </TabControl>
- </DockPanel>
- <StackPanel
- Grid.Row="1"
- Grid.ColumnSpan="2"
- Orientation="Horizontal"
- Spacing="8"
- HorizontalAlignment="Center"
- VerticalAlignment="Center">
- <TextBlock VerticalAlignment="Center">Tab Placement:</TextBlock>
- <ComboBox SelectedIndex="{Binding TabPlacement, Mode=TwoWay}" Width="100">
- <ComboBoxItem>Left</ComboBoxItem>
- <ComboBoxItem>Bottom</ComboBoxItem>
- <ComboBoxItem>Right</ComboBoxItem>
- <ComboBoxItem>Top</ComboBoxItem>
- </ComboBox>
- <CheckBox Name="UseContentTemplates">Set TabItem.ContentTemplate</CheckBox>
- </StackPanel>
- </Grid>
- </DockPanel>
- </UserControl>
|