diff --git a/HandyControl/Controls/Cover/CoverView/CoverView.cs b/HandyControl/Controls/Cover/CoverView/CoverView.cs
index 53a987d7..03dfa5ab 100644
--- a/HandyControl/Controls/Cover/CoverView/CoverView.cs
+++ b/HandyControl/Controls/Cover/CoverView/CoverView.cs
@@ -350,6 +350,13 @@ namespace HandyControl.Controls
{
if (ItemsHost == null) return;
+ if (e.Action == NotifyCollectionChangedAction.Reset)
+ {
+ ClearItems();
+ ItemsHost?.Children.Clear();
+ return;
+ }
+
if (e.OldItems != null)
{
foreach (var item in e.OldItems)
diff --git a/HandyControlDemo/HandyControlDemo.csproj b/HandyControlDemo/HandyControlDemo.csproj
index 66461f61..af034a28 100644
--- a/HandyControlDemo/HandyControlDemo.csproj
+++ b/HandyControlDemo/HandyControlDemo.csproj
@@ -337,7 +337,7 @@
-
+
diff --git a/HandyControlDemo/UserControl/Controls/CoverViewDemoCtl.xaml b/HandyControlDemo/UserControl/Controls/CoverViewDemoCtl.xaml
index 1b4c1e58..43e57342 100644
--- a/HandyControlDemo/UserControl/Controls/CoverViewDemoCtl.xaml
+++ b/HandyControlDemo/UserControl/Controls/CoverViewDemoCtl.xaml
@@ -6,21 +6,19 @@
DataContext="{Binding CoverView,Source={StaticResource Locator}}"
Background="{DynamicResource RegionBrush}">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/HandyControlDemo/ViewModel/DemoViewModelBase.cs b/HandyControlDemo/ViewModel/DemoViewModelBase!1.cs
similarity index 100%
rename from HandyControlDemo/ViewModel/DemoViewModelBase.cs
rename to HandyControlDemo/ViewModel/DemoViewModelBase!1.cs
diff --git a/Net40/HandyControlDemo_Net40/Data/Model/CoverViewDemoModel.cs b/Net40/HandyControlDemo_Net40/Data/Model/CoverViewDemoModel.cs
new file mode 100644
index 00000000..6113440b
--- /dev/null
+++ b/Net40/HandyControlDemo_Net40/Data/Model/CoverViewDemoModel.cs
@@ -0,0 +1,9 @@
+namespace HandyControlDemo.Data
+{
+ public class CoverViewDemoModel
+ {
+ public string ImgPath { get; set; }
+
+ public string BackgroundToken { get; set; }
+ }
+}
\ No newline at end of file
diff --git a/Net40/HandyControlDemo_Net40/HandyControlDemo_Net40.csproj b/Net40/HandyControlDemo_Net40/HandyControlDemo_Net40.csproj
index adcbe810..4fdc78d9 100644
--- a/Net40/HandyControlDemo_Net40/HandyControlDemo_Net40.csproj
+++ b/Net40/HandyControlDemo_Net40/HandyControlDemo_Net40.csproj
@@ -84,6 +84,7 @@
+
@@ -97,6 +98,7 @@
Lang.en.resx
+
@@ -313,6 +315,8 @@
+
+
diff --git a/Net40/HandyControlDemo_Net40/Resources/Themes/Basic/Converters.xaml b/Net40/HandyControlDemo_Net40/Resources/Themes/Basic/Converters.xaml
index f979cb7f..82870e28 100644
--- a/Net40/HandyControlDemo_Net40/Resources/Themes/Basic/Converters.xaml
+++ b/Net40/HandyControlDemo_Net40/Resources/Themes/Basic/Converters.xaml
@@ -3,5 +3,6 @@
xmlns:converter="clr-namespace:HandyControlDemo.Tools.Converter">
+
\ No newline at end of file
diff --git a/Net40/HandyControlDemo_Net40/Service/DataService.cs b/Net40/HandyControlDemo_Net40/Service/DataService.cs
index 94a9f81e..f6502847 100644
--- a/Net40/HandyControlDemo_Net40/Service/DataService.cs
+++ b/Net40/HandyControlDemo_Net40/Service/DataService.cs
@@ -1,8 +1,10 @@
using System;
using System.Collections.Generic;
+using System.Collections.ObjectModel;
using System.Globalization;
using System.Linq;
using System.Net;
+using HandyControl.Data;
using HandyControlDemo.Data;
using HandyControlDemo.Tools.Converter;
using Newtonsoft.Json;
@@ -125,5 +127,62 @@ namespace HandyControlDemo.Service
}
};
}
+
+ internal ObservableCollection GetCoverViewDemoDataList()
+ {
+ return new ObservableCollection
+ {
+ new CoverViewDemoModel
+ {
+ ImgPath = "/HandyControlDemo;component/Resources/Img/Album/1.jpg",
+ BackgroundToken = ResourceToken.SuccessBrush
+ },
+ new CoverViewDemoModel
+ {
+ ImgPath = "/HandyControlDemo;component/Resources/Img/Album/2.jpg",
+ BackgroundToken = ResourceToken.PrimaryBrush
+ },
+ new CoverViewDemoModel
+ {
+ ImgPath = "/HandyControlDemo;component/Resources/Img/Album/3.jpg",
+ BackgroundToken = ResourceToken.WarningBrush
+ },
+ new CoverViewDemoModel
+ {
+ ImgPath = "/HandyControlDemo;component/Resources/Img/Album/4.jpg",
+ BackgroundToken = ResourceToken.DangerBrush
+ },
+ new CoverViewDemoModel
+ {
+ ImgPath = "/HandyControlDemo;component/Resources/Img/Album/5.jpg",
+ BackgroundToken = ResourceToken.SuccessBrush
+ },
+ new CoverViewDemoModel
+ {
+ ImgPath = "/HandyControlDemo;component/Resources/Img/Album/6.jpg",
+ BackgroundToken = ResourceToken.PrimaryBrush
+ },
+ new CoverViewDemoModel
+ {
+ ImgPath = "/HandyControlDemo;component/Resources/Img/Album/7.jpg",
+ BackgroundToken = ResourceToken.InfoBrush
+ },
+ new CoverViewDemoModel
+ {
+ ImgPath = "/HandyControlDemo;component/Resources/Img/Album/8.jpg",
+ BackgroundToken = ResourceToken.WarningBrush
+ },
+ new CoverViewDemoModel
+ {
+ ImgPath = "/HandyControlDemo;component/Resources/Img/Album/9.jpg",
+ BackgroundToken = ResourceToken.PrimaryBrush
+ },
+ new CoverViewDemoModel
+ {
+ ImgPath = "/HandyControlDemo;component/Resources/Img/Album/10.jpg",
+ BackgroundToken = ResourceToken.DangerBrush
+ }
+ };
+ }
}
}
\ No newline at end of file
diff --git a/Net40/HandyControlDemo_Net40/Tools/Converter/String2BrushConverter.cs b/Net40/HandyControlDemo_Net40/Tools/Converter/String2BrushConverter.cs
new file mode 100644
index 00000000..e837c305
--- /dev/null
+++ b/Net40/HandyControlDemo_Net40/Tools/Converter/String2BrushConverter.cs
@@ -0,0 +1,21 @@
+using System;
+using System.Globalization;
+using System.Windows.Data;
+using System.Windows.Media;
+using HandyControl.Tools;
+
+namespace HandyControlDemo.Tools.Converter
+{
+ public class String2BrushConverter : IValueConverter
+ {
+ public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ return value is string str ? ResourceHelper.GetResource(str) : default(Brush);
+ }
+
+ public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
+ {
+ throw new NotImplementedException();
+ }
+ }
+}
\ No newline at end of file
diff --git a/Net40/HandyControlDemo_Net40/UserControl/Controls/CoverViewDemoCtl.xaml b/Net40/HandyControlDemo_Net40/UserControl/Controls/CoverViewDemoCtl.xaml
index 8d52fb5f..f00e130e 100644
--- a/Net40/HandyControlDemo_Net40/UserControl/Controls/CoverViewDemoCtl.xaml
+++ b/Net40/HandyControlDemo_Net40/UserControl/Controls/CoverViewDemoCtl.xaml
@@ -3,89 +3,22 @@
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:HandyControl.Controls;assembly=HandyControl"
xmlns:langs="clr-namespace:HandyControlDemo.Properties.Langs"
+ DataContext="{Binding CoverView,Source={StaticResource Locator}}"
Background="{DynamicResource RegionBrush}">
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
+
+
+
+
+
+
+
+
+
+
+
+
+
-
+
\ No newline at end of file
diff --git a/Net40/HandyControlDemo_Net40/ViewModel/Common/ComboBoxDemoViewModel.cs b/Net40/HandyControlDemo_Net40/ViewModel/Common/ComboBoxDemoViewModel.cs
index 5d428f2d..b2d3f056 100644
--- a/Net40/HandyControlDemo_Net40/ViewModel/Common/ComboBoxDemoViewModel.cs
+++ b/Net40/HandyControlDemo_Net40/ViewModel/Common/ComboBoxDemoViewModel.cs
@@ -1,25 +1,9 @@
-using System.Collections.Generic;
-using GalaSoft.MvvmLight;
-using HandyControlDemo.Service;
+using HandyControlDemo.Service;
namespace HandyControlDemo.ViewModel
{
- public class ComboBoxDemoViewModel : ViewModelBase
+ public class ComboBoxDemoViewModel : DemoViewModelBase
{
- ///
- /// 数据列表
- ///
- private List _dataList;
-
- ///
- /// 数据列表
- ///
- public List DataList
- {
- get => _dataList;
- set => Set(nameof(DataList), ref _dataList, value);
- }
-
public ComboBoxDemoViewModel(DataService dataService) => DataList = dataService.GetComboBoxDemoDataList();
}
}
\ No newline at end of file
diff --git a/Net40/HandyControlDemo_Net40/ViewModel/Controls/CoverViewModel.cs b/Net40/HandyControlDemo_Net40/ViewModel/Controls/CoverViewModel.cs
new file mode 100644
index 00000000..6efbf35a
--- /dev/null
+++ b/Net40/HandyControlDemo_Net40/ViewModel/Controls/CoverViewModel.cs
@@ -0,0 +1,10 @@
+using HandyControlDemo.Data;
+using HandyControlDemo.Service;
+
+namespace HandyControlDemo.ViewModel
+{
+ public class CoverViewModel : DemoViewModelBase
+ {
+ public CoverViewModel(DataService dataService) => DataList = dataService.GetCoverViewDemoDataList();
+ }
+}
\ No newline at end of file
diff --git a/Net40/HandyControlDemo_Net40/ViewModel/Controls/PaginationDemoViewModel.cs b/Net40/HandyControlDemo_Net40/ViewModel/Controls/PaginationDemoViewModel.cs
index ee63dd60..cace512a 100644
--- a/Net40/HandyControlDemo_Net40/ViewModel/Controls/PaginationDemoViewModel.cs
+++ b/Net40/HandyControlDemo_Net40/ViewModel/Controls/PaginationDemoViewModel.cs
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using System.Linq;
-using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using HandyControl.Data;
using HandyControlDemo.Data;
@@ -8,27 +7,13 @@ using HandyControlDemo.Service;
namespace HandyControlDemo.ViewModel
{
- public class PaginationDemoViewModel : ViewModelBase
+ public class PaginationDemoViewModel : DemoViewModelBase
{
///
/// 所有数据
///
private readonly List _totalDataList;
- ///
- /// 显示的数据
- ///
- private List _dataList;
-
- ///
- /// 显示的数据
- ///
- public List DataList
- {
- get => _dataList;
- set => Set(nameof(DataList), ref _dataList, value);
- }
-
///
/// 页码
///
diff --git a/Net40/HandyControlDemo_Net40/ViewModel/Controls/StepBarDemoViewModel.cs b/Net40/HandyControlDemo_Net40/ViewModel/Controls/StepBarDemoViewModel.cs
index 820a180f..1af4d2a5 100644
--- a/Net40/HandyControlDemo_Net40/ViewModel/Controls/StepBarDemoViewModel.cs
+++ b/Net40/HandyControlDemo_Net40/ViewModel/Controls/StepBarDemoViewModel.cs
@@ -1,7 +1,5 @@
-using System.Collections.Generic;
-using System.Linq;
+using System.Linq;
using System.Windows.Controls;
-using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using HandyControl.Controls;
using HandyControlDemo.Data;
@@ -9,26 +7,9 @@ using HandyControlDemo.Service;
namespace HandyControlDemo.ViewModel
{
- public class StepBarDemoViewModel : ViewModelBase
+ public class StepBarDemoViewModel : DemoViewModelBase
{
- ///
- /// 数据列表
- ///
- private List _dataList;
-
- ///
- /// 数据列表
- ///
- public List DataList
- {
- get => _dataList;
- set => Set(nameof(DataList), ref _dataList, value);
- }
-
- public StepBarDemoViewModel(DataService dataService)
- {
- DataList = dataService.GetStepBarDemoDataList();
- }
+ public StepBarDemoViewModel(DataService dataService) => DataList = dataService.GetStepBarDemoDataList();
private RelayCommand _nextCmd;
diff --git a/Net40/HandyControlDemo_Net40/ViewModel/DemoViewModelBase!1.cs b/Net40/HandyControlDemo_Net40/ViewModel/DemoViewModelBase!1.cs
new file mode 100644
index 00000000..e394d971
--- /dev/null
+++ b/Net40/HandyControlDemo_Net40/ViewModel/DemoViewModelBase!1.cs
@@ -0,0 +1,22 @@
+using System.Collections.Generic;
+using GalaSoft.MvvmLight;
+
+namespace HandyControlDemo.ViewModel
+{
+ public class DemoViewModelBase : ViewModelBase
+ {
+ ///
+ /// 数据列表
+ ///
+ private IList _dataList;
+
+ ///
+ /// 数据列表
+ ///
+ public IList DataList
+ {
+ get => _dataList;
+ set => Set(nameof(DataList), ref _dataList, value);
+ }
+ }
+}
\ No newline at end of file
diff --git a/Net40/HandyControlDemo_Net40/ViewModel/Main/ContributorsViewModel.cs b/Net40/HandyControlDemo_Net40/ViewModel/Main/ContributorsViewModel.cs
index 4662ca46..2398f0d6 100644
--- a/Net40/HandyControlDemo_Net40/ViewModel/Main/ContributorsViewModel.cs
+++ b/Net40/HandyControlDemo_Net40/ViewModel/Main/ContributorsViewModel.cs
@@ -1,27 +1,11 @@
-using System.Collections.Generic;
-using System.Threading;
-using GalaSoft.MvvmLight;
+using System.Threading;
using HandyControlDemo.Data;
using HandyControlDemo.Service;
namespace HandyControlDemo.ViewModel
{
- public class ContributorsViewModel : ViewModelBase
+ public class ContributorsViewModel : DemoViewModelBase
{
- ///
- /// 数据列表
- ///
- private List _dataList;
-
- ///
- /// 数据列表
- ///
- public List DataList
- {
- get => _dataList;
- set => Set(nameof(DataList), ref _dataList, value);
- }
-
public ContributorsViewModel(DataService dataService)
{
ThreadPool.QueueUserWorkItem(state =>
diff --git a/Net40/HandyControlDemo_Net40/ViewModel/Main/MainViewModel.cs b/Net40/HandyControlDemo_Net40/ViewModel/Main/MainViewModel.cs
index 4c34759a..123404e7 100644
--- a/Net40/HandyControlDemo_Net40/ViewModel/Main/MainViewModel.cs
+++ b/Net40/HandyControlDemo_Net40/ViewModel/Main/MainViewModel.cs
@@ -1,7 +1,5 @@
using System;
-using System.Collections.Generic;
using System.Windows.Controls;
-using GalaSoft.MvvmLight;
using GalaSoft.MvvmLight.Command;
using GalaSoft.MvvmLight.Messaging;
using HandyControlDemo.Data;
@@ -10,7 +8,7 @@ using HandyControlDemo.Tools;
namespace HandyControlDemo.ViewModel
{
- public class MainViewModel : ViewModelBase
+ public class MainViewModel : DemoViewModelBase
{
#region 字段
@@ -24,11 +22,6 @@ namespace HandyControlDemo.ViewModel
///
private object _subContent;
- ///
- /// 数据列表
- ///
- private List _dataList;
-
///
/// 当前选中的列表项
///
@@ -57,15 +50,6 @@ namespace HandyControlDemo.ViewModel
#region 属性
- ///
- /// 数据列表
- ///
- public List DataList
- {
- get => _dataList;
- set => Set(nameof(DataList), ref _dataList, value);
- }
-
///
/// 子内容
///
diff --git a/Net40/HandyControlDemo_Net40/ViewModel/ViewModelLocator.cs b/Net40/HandyControlDemo_Net40/ViewModel/ViewModelLocator.cs
index f49a8a61..ac72e0e7 100644
--- a/Net40/HandyControlDemo_Net40/ViewModel/ViewModelLocator.cs
+++ b/Net40/HandyControlDemo_Net40/ViewModel/ViewModelLocator.cs
@@ -23,6 +23,7 @@ namespace HandyControlDemo.ViewModel
SimpleIoc.Default.Register();
SimpleIoc.Default.Register();
SimpleIoc.Default.Register();
+ SimpleIoc.Default.Register();
}
public static ViewModelLocator Instance => new Lazy(() =>
@@ -48,6 +49,8 @@ namespace HandyControlDemo.ViewModel
public ChatBoxViewModel ChatBox => new ChatBoxViewModel();
+ public CoverViewModel CoverView => ServiceLocator.Current.GetInstance();
+
#endregion
}
}
\ No newline at end of file
diff --git a/Net40/HandyControl_Net40/Controls/Base/HeaderedSelectableItem.cs b/Net40/HandyControl_Net40/Controls/Base/HeaderedSelectableItem.cs
index 480be514..98196d26 100644
--- a/Net40/HandyControl_Net40/Controls/Base/HeaderedSelectableItem.cs
+++ b/Net40/HandyControl_Net40/Controls/Base/HeaderedSelectableItem.cs
@@ -12,5 +12,14 @@ namespace HandyControl.Controls
get => GetValue(HeaderProperty);
set => SetValue(HeaderProperty, value);
}
+
+ public static readonly DependencyProperty HeaderTemplateProperty = DependencyProperty.Register(
+ "HeaderTemplate", typeof(DataTemplate), typeof(HeaderedSelectableItem), new PropertyMetadata(default(DataTemplate)));
+
+ public DataTemplate HeaderTemplate
+ {
+ get => (DataTemplate)GetValue(HeaderTemplateProperty);
+ set => SetValue(HeaderTemplateProperty, value);
+ }
}
}
\ No newline at end of file
diff --git a/Net40/HandyControl_Net40/Controls/Cover/CoverView/CoverView.cs b/Net40/HandyControl_Net40/Controls/Cover/CoverView/CoverView.cs
index ef0d8483..65984c6c 100644
--- a/Net40/HandyControl_Net40/Controls/Cover/CoverView/CoverView.cs
+++ b/Net40/HandyControl_Net40/Controls/Cover/CoverView/CoverView.cs
@@ -1,4 +1,7 @@
-using System.Windows;
+using System.Collections;
+using System.Collections.Generic;
+using System.Collections.Specialized;
+using System.Windows;
using System.Windows.Data;
using HandyControl.Data;
using HandyControl.Tools;
@@ -11,6 +14,10 @@ namespace HandyControl.Controls
private CoverViewItem _selectedItem;
+ private IEnumerable _itemsSourceInternal;
+
+ private readonly Dictionary