6 changed files with 73 additions and 0 deletions
@ -0,0 +1,21 @@ |
|||
using MiniMvvm; |
|||
|
|||
namespace VirtualizationDemo.ViewModels; |
|||
|
|||
public class ExpanderItemViewModel : ViewModelBase |
|||
{ |
|||
private string? _header; |
|||
private bool _isExpanded; |
|||
|
|||
public string? Header |
|||
{ |
|||
get => _header; |
|||
set => RaiseAndSetIfChanged(ref _header, value); |
|||
} |
|||
|
|||
public bool IsExpanded |
|||
{ |
|||
get => _isExpanded; |
|||
set => RaiseAndSetIfChanged(ref _isExpanded, value); |
|||
} |
|||
} |
|||
@ -0,0 +1,17 @@ |
|||
using System.Collections.ObjectModel; |
|||
using System.Linq; |
|||
|
|||
namespace VirtualizationDemo.ViewModels; |
|||
|
|||
internal class ExpanderPageViewModel |
|||
{ |
|||
public ExpanderPageViewModel() |
|||
{ |
|||
Items = new(Enumerable.Range(0, 100).Select(x => new ExpanderItemViewModel |
|||
{ |
|||
Header = $"Item {x}", |
|||
})); |
|||
} |
|||
|
|||
public ObservableCollection<ExpanderItemViewModel> Items { get; set; } |
|||
} |
|||
@ -0,0 +1,18 @@ |
|||
<UserControl xmlns="https://github.com/avaloniaui" |
|||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" |
|||
xmlns:d="http://schemas.microsoft.com/expression/blend/2008" |
|||
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" |
|||
xmlns:vm="using:VirtualizationDemo.ViewModels" |
|||
mc:Ignorable="d" d:DesignWidth="800" d:DesignHeight="450" |
|||
x:Class="VirtualizationDemo.Views.ExpanderPageView" |
|||
x:DataType="vm:ExpanderPageViewModel"> |
|||
<ListBox ItemsSource="{Binding Items}"> |
|||
<ListBox.ItemTemplate> |
|||
<DataTemplate> |
|||
<Expander Header="{Binding Header}" IsExpanded="{Binding IsExpanded}"> |
|||
<Border Width="200" Height="300"/> |
|||
</Expander> |
|||
</DataTemplate> |
|||
</ListBox.ItemTemplate> |
|||
</ListBox> |
|||
</UserControl> |
|||
@ -0,0 +1,13 @@ |
|||
using Avalonia; |
|||
using Avalonia.Controls; |
|||
using Avalonia.Markup.Xaml; |
|||
|
|||
namespace VirtualizationDemo.Views; |
|||
|
|||
public partial class ExpanderPageView : UserControl |
|||
{ |
|||
public ExpanderPageView() |
|||
{ |
|||
InitializeComponent(); |
|||
} |
|||
} |
|||
Loading…
Reference in new issue