csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
121 lines
6.0 KiB
121 lines
6.0 KiB
<ContentPage
|
|
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
|
x:Class="ControlCatalog.Pages.TabControlPage"
|
|
xmlns="https://github.com/avaloniaui"
|
|
Header="TabControl"
|
|
xmlns:viewModels="using:ControlCatalog.ViewModels"
|
|
x:DataType="viewModels:TabControlPageViewModel">
|
|
<ContentPage.Resources>
|
|
<StreamGeometry x:Key="LeafIcon">M2.002 4.705V9a6 6 0 0 0 6.293 5.993 7 7 0 0 0 1.259 2.394l-2.33 2.329a.75.75 0 0 0 1.06 1.06l2.33-2.329a6.999 6.999 0 0 0 11.389-5.451V7.748a1.75 1.75 0 0 0-1.75-1.75h-5.249c-.583 0-1.15.071-1.692.205A6 6 0 0 0 8.002 3H3.707c-.941 0-1.705.763-1.705 1.705m9.682 12.674 4.096-4.094a.75.75 0 0 0-1.06-1.06l-4.097 4.094a5.499 5.499 0 0 1 4.382-8.821h5.248a.25.25 0 0 1 .25.25v5.248a5.499 5.499 0 0 1-8.82 4.383M8.002 4.5c1.657 0 3.105.895 3.886 2.228a7.03 7.03 0 0 0-2.71 2.39L7.28 7.22a.75.75 0 0 0-1.06 1.06l2.237 2.238a7 7 0 0 0-.433 2.982h-.022a4.5 4.5 0 0 1-4.5-4.5V4.705c0-.113.092-.205.205-.205z</StreamGeometry>
|
|
</ContentPage.Resources>
|
|
<DockPanel Classes.WithContentTemplates="{Binding IsChecked, ElementName=UseContentTemplates}">
|
|
<DockPanel.Styles>
|
|
<Style Selector="DockPanel.WithContentTemplates">
|
|
<Style Selector="^ TabItem">
|
|
<Setter Property="ContentTemplate">
|
|
<DataTemplate x:DataType="x:Object">
|
|
<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">
|
|
<TabItem.Icon>
|
|
<PathIcon
|
|
Width="16"
|
|
Height="16"
|
|
Data="{StaticResource LeafIcon}"/>
|
|
</TabItem.Icon>
|
|
<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>
|
|
</ContentPage>
|
|
|