3 changed files with 79 additions and 0 deletions
@ -0,0 +1,33 @@ |
|||
<UserControl xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
x:Class="ControlCatalog.Pages.TabStripPage" |
|||
xmlns="https://github.com/avaloniaui"> |
|||
<StackPanel Orientation="Vertical" Spacing="4"> |
|||
<TextBlock Classes="h1">TabStrip</TextBlock> |
|||
<TextBlock Classes="h2">A control which displays a selectable strip of tabs</TextBlock> |
|||
|
|||
<Separator Margin="0 16"/> |
|||
|
|||
<TextBlock Classes="h1">Defined in XAML</TextBlock> |
|||
<TabStrip> |
|||
<TabStripItem>Item 1</TabStripItem> |
|||
<TabStripItem>Item 2</TabStripItem> |
|||
<TabStripItem IsEnabled="False">Disabled</TabStripItem> |
|||
</TabStrip> |
|||
|
|||
<Separator Margin="0 16"/> |
|||
|
|||
<TextBlock Classes="h1">Dynamically generated</TextBlock> |
|||
<TabStrip Items="{Binding}"> |
|||
<TabStrip.Styles> |
|||
<Style Selector="TabStripItem"> |
|||
<Setter Property="IsEnabled" Value="{Binding IsEnabled}"/> |
|||
</Style> |
|||
</TabStrip.Styles> |
|||
<TabStrip.ItemTemplate> |
|||
<DataTemplate> |
|||
<TextBlock Text="{Binding Header}"/> |
|||
</DataTemplate> |
|||
</TabStrip.ItemTemplate> |
|||
</TabStrip> |
|||
</StackPanel> |
|||
</UserControl> |
|||
@ -0,0 +1,45 @@ |
|||
using System; |
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Markup.Xaml; |
|||
using Avalonia.Media.Imaging; |
|||
using Avalonia.Platform; |
|||
|
|||
namespace ControlCatalog.Pages |
|||
{ |
|||
public class TabStripPage : UserControl |
|||
{ |
|||
public TabStripPage() |
|||
{ |
|||
InitializeComponent(); |
|||
|
|||
DataContext = new[] |
|||
{ |
|||
new TabStripItemViewModel |
|||
{ |
|||
Header = "Item 1", |
|||
}, |
|||
new TabStripItemViewModel |
|||
{ |
|||
Header = "Item 2", |
|||
}, |
|||
new TabStripItemViewModel |
|||
{ |
|||
Header = "Disabled", |
|||
IsEnabled = false, |
|||
}, |
|||
}; |
|||
} |
|||
|
|||
private void InitializeComponent() |
|||
{ |
|||
AvaloniaXamlLoader.Load(this); |
|||
} |
|||
|
|||
private class TabStripItemViewModel |
|||
{ |
|||
public string Header { get; set; } |
|||
public bool IsEnabled { get; set; } = true; |
|||
} |
|||
} |
|||
} |
|||
Loading…
Reference in new issue