|
|
@ -1,7 +1,10 @@ |
|
|
// Copyright (c) The Avalonia Project. All rights reserved.
|
|
|
// Copyright (c) The Avalonia Project. All rights reserved.
|
|
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|
|
// Licensed under the MIT license. See licence.md file in the project root for full license information.
|
|
|
|
|
|
|
|
|
|
|
|
using System.Collections.Generic; |
|
|
using Avalonia.Controls; |
|
|
using Avalonia.Controls; |
|
|
|
|
|
using Avalonia.Controls.Primitives; |
|
|
|
|
|
using Avalonia.Layout; |
|
|
using Avalonia.Logging; |
|
|
using Avalonia.Logging; |
|
|
using Avalonia.UnitTests; |
|
|
using Avalonia.UnitTests; |
|
|
using Xunit; |
|
|
using Xunit; |
|
|
@ -67,5 +70,61 @@ namespace Avalonia.Markup.Xaml.UnitTests.Xaml |
|
|
Assert.True(called); |
|
|
Assert.True(called); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
[Fact] |
|
|
|
|
|
public void Can_Bind_Between_TabStrip_And_Carousel() |
|
|
|
|
|
{ |
|
|
|
|
|
using (UnitTestApplication.Start(TestServices.StyledWindow)) |
|
|
|
|
|
{ |
|
|
|
|
|
var xaml = @"
|
|
|
|
|
|
<Window xmlns='https://github.com/avaloniaui'>
|
|
|
|
|
|
<DockPanel> |
|
|
|
|
|
<TabStrip Name='strip' DockPanel.Dock='Top' Items='{Binding Items}' SelectedIndex='0'> |
|
|
|
|
|
<TabStrip.DataTemplates> |
|
|
|
|
|
<DataTemplate> |
|
|
|
|
|
<TextBlock Text='{Binding Header}'/> |
|
|
|
|
|
</DataTemplate> |
|
|
|
|
|
</TabStrip.DataTemplates> |
|
|
|
|
|
</TabStrip> |
|
|
|
|
|
<Carousel Name='carousel' Items='{Binding Items}' SelectedIndex='{Binding #strip.SelectedIndex}'> |
|
|
|
|
|
<Carousel.DataTemplates> |
|
|
|
|
|
<DataTemplate> |
|
|
|
|
|
<TextBlock Text='{Binding Detail}'/> |
|
|
|
|
|
</DataTemplate> |
|
|
|
|
|
</Carousel.DataTemplates> |
|
|
|
|
|
</Carousel> |
|
|
|
|
|
</DockPanel> |
|
|
|
|
|
</Window>";
|
|
|
|
|
|
var loader = new AvaloniaXamlLoader(); |
|
|
|
|
|
var window = (Window)loader.Load(xaml); |
|
|
|
|
|
var strip = window.FindControl<TabStrip>("strip"); |
|
|
|
|
|
var carousel = window.FindControl<Carousel>("carousel"); |
|
|
|
|
|
|
|
|
|
|
|
window.DataContext = new ItemsViewModel |
|
|
|
|
|
{ |
|
|
|
|
|
Items = new[] |
|
|
|
|
|
{ |
|
|
|
|
|
new ItemViewModel { Header = "Item1", Detail = "Detail1" }, |
|
|
|
|
|
new ItemViewModel { Header = "Item2", Detail = "Detail2" }, |
|
|
|
|
|
} |
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
window.Show(); |
|
|
|
|
|
|
|
|
|
|
|
Assert.Equal(0, strip.SelectedIndex); |
|
|
|
|
|
Assert.Equal(0, carousel.SelectedIndex); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private class ItemsViewModel |
|
|
|
|
|
{ |
|
|
|
|
|
public IList<ItemViewModel> Items { get; set; } |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private class ItemViewModel |
|
|
|
|
|
{ |
|
|
|
|
|
public string Header { get; set; } |
|
|
|
|
|
public string Detail { get; set; } |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|