Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Workaround for TabControl issue upstream #70

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,7 @@ private async Task SelectFilesAsync()
{
SelectedFiles = await SelectFilesInteraction.HandleAsync("Hello from Avalonia");
}

public override string ToString() => "Custom Interaction Sample";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,5 +43,7 @@ private async Task SelectFiles()
{
SelectedFiles = await _SelectFilesInteraction.Handle("Hello from Avalonia");
}

public override string ToString() => "ReactiveUI Interaction Sample";
}
}
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
namespace MvvmDialogSample.ViewModels
using System;
using System.Collections.Generic;

namespace MvvmDialogSample.ViewModels
{
public class MainWindowViewModel : ViewModelBase
{
public InteractionViewModel InteractionSample { get; } = new InteractionViewModel();

public CustomInteractionViewModel CustomInteractionViewModel { get; } = new CustomInteractionViewModel();

/// <summary>
/// Gets a list of available tabs
/// </summary>
public object[] Samples { get; } =
{
new InteractionViewModel(),
new CustomInteractionViewModel()
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
xmlns:vm="using:MvvmDialogSample.ViewModels"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:system="clr-namespace:System;assembly=System.Runtime"
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450"
x:Class="MvvmDialogSample.Views.MainWindow"
Icon="/Assets/avalonia-logo.ico"
Expand All @@ -15,12 +16,20 @@
<vm:MainWindowViewModel/>
</Design.DataContext>

<TabControl>
<TabItem Header="Interaction">
<v:InteractionView DataContext="{Binding InteractionSample}" />
</TabItem>
<TabItem Header="Custom Interaction">
<v:CustomInteractionView DataContext="{Binding CustomInteractionViewModel}" />
</TabItem>
<TabControl ItemsSource="{Binding Samples}">
<TabControl.ContentTemplate>
<DataTemplate DataType="system:Object">
<ContentControl Content="{Binding}">
<ContentControl.DataTemplates>
<DataTemplate DataType="vm:InteractionViewModel">
<v:InteractionView />
</DataTemplate>
<DataTemplate DataType="vm:CustomInteractionViewModel">
<v:CustomInteractionView />
</DataTemplate>
</ContentControl.DataTemplates>
</ContentControl>
</DataTemplate>
</TabControl.ContentTemplate>
</TabControl>
</Window>