Rename
This commit is contained in:
Родитель
b592f998bd
Коммит
606f0df9b8
|
@ -31,7 +31,7 @@
|
|||
HorizontalAlignment="Center">
|
||||
<ItemsControl Items="{Binding Tiles}">
|
||||
<ItemsControl.Styles>
|
||||
<Style Selector="ItemsControl > ContentPresenter" x:DataType="tc:TileItem">
|
||||
<Style Selector="ItemsControl > ContentPresenter" x:DataType="tc:TileViewModel">
|
||||
<!-- <Setter Property="Grid.Column" Value="{Binding CurrentTilePreset.Column}"/> -->
|
||||
<!-- <Setter Property="Grid.Row" Value="{Binding CurrentTilePreset.Row}"/> -->
|
||||
<!-- <Setter Property="Grid.ColumnSpan" Value="{Binding CurrentTilePreset.ColumnSpan}"/> -->
|
||||
|
@ -50,7 +50,7 @@
|
|||
</ItemsPanelTemplate>
|
||||
</ItemsControl.ItemsPanel>
|
||||
<ItemsControl.DataTemplates>
|
||||
<DataTemplate DataType="tc:TileItem">
|
||||
<DataTemplate DataType="tc:TileViewModel">
|
||||
<Border Background="{Binding Background}">
|
||||
<StackPanel x:CompileBindings="False"
|
||||
Background="Gray"
|
||||
|
|
|
@ -8,17 +8,17 @@ namespace GridDemo.ViewModels
|
|||
{
|
||||
public class MainWindowViewModel : ViewModelBase
|
||||
{
|
||||
private ObservableCollection<TileItem>? _tiles;
|
||||
private ObservableCollection<TileLayout>? _layouts;
|
||||
private ObservableCollection<TileViewModel>? _tiles;
|
||||
private ObservableCollection<TileLayoutViewModel>? _layouts;
|
||||
private int _layoutIndex;
|
||||
|
||||
public ObservableCollection<TileItem>? Tiles
|
||||
public ObservableCollection<TileViewModel>? Tiles
|
||||
{
|
||||
get => _tiles;
|
||||
set => this.RaiseAndSetIfChanged(ref _tiles, value);
|
||||
}
|
||||
|
||||
public ObservableCollection<TileLayout>? Layouts
|
||||
public ObservableCollection<TileLayoutViewModel>? Layouts
|
||||
{
|
||||
get => _layouts;
|
||||
set => this.RaiseAndSetIfChanged(ref _layouts, value);
|
||||
|
@ -34,78 +34,78 @@ namespace GridDemo.ViewModels
|
|||
}
|
||||
}
|
||||
|
||||
public TileLayout? CurrentLayout => Layouts?[LayoutIndex];
|
||||
public TileLayoutViewModel? CurrentLayout => Layouts?[LayoutIndex];
|
||||
|
||||
public MainWindowViewModel()
|
||||
{
|
||||
LayoutIndex = 2;
|
||||
|
||||
Layouts = new ObservableCollection<TileLayout>()
|
||||
Layouts = new ObservableCollection<TileLayoutViewModel>()
|
||||
{
|
||||
new TileLayout("Small", "228,228,228,228,228", "126"),
|
||||
new TileLayout("Normal", "228,228,228", "126,252"),
|
||||
new TileLayout("Wide", "228,228", "126,252,252"),
|
||||
new TileLayoutViewModel("Small", "228,228,228,228,228", "126"),
|
||||
new TileLayoutViewModel("Normal", "228,228,228", "126,252"),
|
||||
new TileLayoutViewModel("Wide", "228,228", "126,252,252"),
|
||||
};
|
||||
|
||||
Tiles = new ObservableCollection<TileItem>()
|
||||
Tiles = new ObservableCollection<TileViewModel>()
|
||||
{
|
||||
// 0
|
||||
new TileItem()
|
||||
new TileViewModel()
|
||||
{
|
||||
Background = Brushes.Red,
|
||||
TilePresets = new ObservableCollection<TilePreset>()
|
||||
TilePresets = new ObservableCollection<TilePresetViewModel>()
|
||||
{
|
||||
new TilePreset(0, 0, 1, 1),
|
||||
new TilePreset(0, 0, 1, 1),
|
||||
new TilePreset(0, 0, 1, 1),
|
||||
new TilePresetViewModel(0, 0, 1, 1),
|
||||
new TilePresetViewModel(0, 0, 1, 1),
|
||||
new TilePresetViewModel(0, 0, 1, 1),
|
||||
},
|
||||
TilePresetIndex = LayoutIndex
|
||||
},
|
||||
// 1
|
||||
new TileItem()
|
||||
new TileViewModel()
|
||||
{
|
||||
Background = Brushes.Green,
|
||||
TilePresets = new ObservableCollection<TilePreset>()
|
||||
TilePresets = new ObservableCollection<TilePresetViewModel>()
|
||||
{
|
||||
new TilePreset(1, 0, 1, 1),
|
||||
new TilePreset(1, 0, 1, 1),
|
||||
new TilePreset(1, 0, 1, 1),
|
||||
new TilePresetViewModel(1, 0, 1, 1),
|
||||
new TilePresetViewModel(1, 0, 1, 1),
|
||||
new TilePresetViewModel(1, 0, 1, 1),
|
||||
},
|
||||
TilePresetIndex = LayoutIndex
|
||||
},
|
||||
// 2
|
||||
new TileItem()
|
||||
new TileViewModel()
|
||||
{
|
||||
Background = Brushes.Blue,
|
||||
TilePresets = new ObservableCollection<TilePreset>()
|
||||
TilePresets = new ObservableCollection<TilePresetViewModel>()
|
||||
{
|
||||
new TilePreset(2, 0, 1, 1),
|
||||
new TilePreset(2, 0, 1, 1),
|
||||
new TilePreset(0, 1, 1, 1),
|
||||
new TilePresetViewModel(2, 0, 1, 1),
|
||||
new TilePresetViewModel(2, 0, 1, 1),
|
||||
new TilePresetViewModel(0, 1, 1, 1),
|
||||
},
|
||||
TilePresetIndex = LayoutIndex
|
||||
},
|
||||
// 3
|
||||
new TileItem()
|
||||
new TileViewModel()
|
||||
{
|
||||
Background = Brushes.Yellow,
|
||||
TilePresets = new ObservableCollection<TilePreset>()
|
||||
TilePresets = new ObservableCollection<TilePresetViewModel>()
|
||||
{
|
||||
new TilePreset(3, 0, 1, 1),
|
||||
new TilePreset(0, 1, 1, 1),
|
||||
new TilePreset(1, 1, 1, 1),
|
||||
new TilePresetViewModel(3, 0, 1, 1),
|
||||
new TilePresetViewModel(0, 1, 1, 1),
|
||||
new TilePresetViewModel(1, 1, 1, 1),
|
||||
},
|
||||
TilePresetIndex = LayoutIndex
|
||||
},
|
||||
// 4
|
||||
new TileItem()
|
||||
new TileViewModel()
|
||||
{
|
||||
Background = Brushes.Black,
|
||||
TilePresets = new ObservableCollection<TilePreset>()
|
||||
TilePresets = new ObservableCollection<TilePresetViewModel>()
|
||||
{
|
||||
new TilePreset(4, 0, 1, 1),
|
||||
new TilePreset(1, 1, 2, 1),
|
||||
new TilePreset(0, 2, 2, 1),
|
||||
new TilePresetViewModel(4, 0, 1, 1),
|
||||
new TilePresetViewModel(1, 1, 2, 1),
|
||||
new TilePresetViewModel(0, 2, 2, 1),
|
||||
},
|
||||
TilePresetIndex = LayoutIndex
|
||||
},
|
||||
|
|
|
@ -2,7 +2,7 @@ using ReactiveUI;
|
|||
|
||||
namespace GridDemo.ViewModels.TileControl
|
||||
{
|
||||
public class TileLayout : ViewModelBase
|
||||
public class TileLayoutViewModel : ViewModelBase
|
||||
{
|
||||
private string? _name;
|
||||
private string? _columnDefinitions;
|
||||
|
@ -26,11 +26,11 @@ namespace GridDemo.ViewModels.TileControl
|
|||
set => this.RaiseAndSetIfChanged(ref _rowDefinitions, value);
|
||||
}
|
||||
|
||||
public TileLayout()
|
||||
public TileLayoutViewModel()
|
||||
{
|
||||
}
|
||||
|
||||
public TileLayout(string name, string columnDefinitions, string rowDefinitions)
|
||||
public TileLayoutViewModel(string name, string columnDefinitions, string rowDefinitions)
|
||||
{
|
||||
Name = name;
|
||||
ColumnDefinitions = columnDefinitions;
|
|
@ -2,7 +2,7 @@ using ReactiveUI;
|
|||
|
||||
namespace GridDemo.ViewModels.TileControl
|
||||
{
|
||||
public class TilePreset : ViewModelBase
|
||||
public class TilePresetViewModel : ViewModelBase
|
||||
{
|
||||
private int _column;
|
||||
private int _row;
|
||||
|
@ -33,11 +33,11 @@ namespace GridDemo.ViewModels.TileControl
|
|||
set => this.RaiseAndSetIfChanged(ref _rowSpan, value);
|
||||
}
|
||||
|
||||
public TilePreset()
|
||||
public TilePresetViewModel()
|
||||
{
|
||||
}
|
||||
|
||||
public TilePreset(int column, int row, int columnSpan, int rowSpan)
|
||||
public TilePresetViewModel(int column, int row, int columnSpan, int rowSpan)
|
||||
{
|
||||
Column = column;
|
||||
Row = row;
|
|
@ -5,12 +5,12 @@ using ReactiveUI;
|
|||
|
||||
namespace GridDemo.ViewModels.TileControl
|
||||
{
|
||||
public class TileItem : ViewModelBase
|
||||
public class TileViewModel : ViewModelBase
|
||||
{
|
||||
private ObservableCollection<TilePreset>? _tilePresets;
|
||||
private ObservableCollection<TilePresetViewModel>? _tilePresets;
|
||||
private int _tilePresetIndex;
|
||||
|
||||
public ObservableCollection<TilePreset>? TilePresets
|
||||
public ObservableCollection<TilePresetViewModel>? TilePresets
|
||||
{
|
||||
get => _tilePresets;
|
||||
set => this.RaiseAndSetIfChanged(ref _tilePresets, value);
|
||||
|
@ -22,7 +22,7 @@ namespace GridDemo.ViewModels.TileControl
|
|||
set => this.RaiseAndSetIfChanged(ref _tilePresetIndex, value);
|
||||
}
|
||||
|
||||
public TileItem()
|
||||
public TileViewModel()
|
||||
{
|
||||
this.WhenAnyValue(x => x.TilePresetIndex)
|
||||
.Subscribe(_ => NotifyPresetChanged());
|
||||
|
@ -36,7 +36,7 @@ namespace GridDemo.ViewModels.TileControl
|
|||
|
||||
public int RowSpan => CurrentTilePreset?.RowSpan ?? 1;
|
||||
|
||||
public TilePreset? CurrentTilePreset => TilePresets?[TilePresetIndex];
|
||||
public TilePresetViewModel? CurrentTilePreset => TilePresets?[TilePresetIndex];
|
||||
|
||||
public IBrush? Background { get; set; }
|
||||
|
Загрузка…
Ссылка в новой задаче