add some demos & styles
1. add window demo 2. add scrollviewer demo 3. add radiobutton style 4. fixed some bugs 5. add research project
This commit is contained in:
1 parent
0baae519cb
commit
fffbdbb4a9
59 files changed
+1114
-159
No files matched your search
@@ -1,7 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using GalaSoft.MvvmLight;
|
||||
using HandyControlDemo.Tools.Converter;
|
||||
using HandyControlDemo.Service;
|
||||
|
||||
namespace HandyControlDemo.ViewModel
|
||||
{
|
||||
@@ -21,16 +20,6 @@ namespace HandyControlDemo.ViewModel
|
||||
set => Set(ref _dataList, value);
|
||||
}
|
||||
|
||||
public ComboBoxDemoViewModel()
|
||||
{
|
||||
var converter = new StringRepeatConverter();
|
||||
var list = new List<string>();
|
||||
for (var i = 1; i <= 9; i++)
|
||||
{
|
||||
list.Add(converter.Convert(Properties.Langs.Lang.Text, null, i, CultureInfo.CurrentCulture)?.ToString());
|
||||
}
|
||||
|
||||
DataList = list;
|
||||
}
|
||||
public ComboBoxDemoViewModel(DataService dataService) => DataList = dataService.GetComboBoxDemoDataList();
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ using GalaSoft.MvvmLight;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
using GalaSoft.MvvmLight.Messaging;
|
||||
using HandyControlDemo.Data;
|
||||
using HandyControlDemo.Service;
|
||||
using HandyControlDemo.Tools;
|
||||
|
||||
namespace HandyControlDemo.ViewModel
|
||||
@@ -28,38 +29,17 @@ namespace HandyControlDemo.ViewModel
|
||||
/// </summary>
|
||||
private List<DemoDataModel> _dataList;
|
||||
|
||||
/// <summary>
|
||||
/// 当前选中的列表项
|
||||
/// </summary>
|
||||
private ListBoxItem _listBoxItemCurrent;
|
||||
|
||||
#endregion
|
||||
|
||||
public MainViewModel()
|
||||
public MainViewModel(DataService dataService)
|
||||
{
|
||||
Messenger.Default.Register<object>(this, MessageToken.LoadShowContent, obj => SubContent = obj);
|
||||
|
||||
var list = new List<DemoDataModel>();
|
||||
for (var i = 1; i <= 6; i++)
|
||||
{
|
||||
var dataList = new List<DemoDataModel>();
|
||||
for (int j = 0; j < 3; j++)
|
||||
{
|
||||
dataList.Add(new DemoDataModel
|
||||
{
|
||||
Index = j,
|
||||
IsSelected = j % 2 == 0,
|
||||
Name = $"SubName{j}",
|
||||
Type = (DemoType)j
|
||||
});
|
||||
}
|
||||
var model = new DemoDataModel
|
||||
{
|
||||
Index = i,
|
||||
IsSelected = i % 2 == 0,
|
||||
Name = $"Name{i}",
|
||||
Type = (DemoType)i,
|
||||
DataList = dataList
|
||||
};
|
||||
list.Add(model);
|
||||
}
|
||||
|
||||
DataList = list;
|
||||
DataList = dataService.GetDemoDataList();
|
||||
}
|
||||
|
||||
#region 属性
|
||||
@@ -116,12 +96,14 @@ namespace HandyControlDemo.ViewModel
|
||||
{
|
||||
if (item.Tag is string tag)
|
||||
{
|
||||
if (item.Content.Equals(ContentTitle)) return;
|
||||
if (Equals(_listBoxItemCurrent, item)) return;
|
||||
_listBoxItemCurrent = item;
|
||||
ContentTitle = item.Content;
|
||||
Messenger.Default.Send(AssemblyHelper.CreateInternalInstance($"UserControl.{tag}"), MessageToken.LoadShowContent);
|
||||
}
|
||||
else
|
||||
{
|
||||
_listBoxItemCurrent = null;
|
||||
ContentTitle = null;
|
||||
SubContent = null;
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Windows;
|
||||
using CommonServiceLocator;
|
||||
using GalaSoft.MvvmLight.Ioc;
|
||||
using HandyControlDemo.Service;
|
||||
|
||||
namespace HandyControlDemo.ViewModel
|
||||
{
|
||||
@@ -11,10 +12,13 @@ namespace HandyControlDemo.ViewModel
|
||||
{
|
||||
ServiceLocator.SetLocatorProvider(() => SimpleIoc.Default);
|
||||
|
||||
SimpleIoc.Default.Register<DataService>();
|
||||
|
||||
SimpleIoc.Default.Register<MainViewModel>();
|
||||
SimpleIoc.Default.Register<GrowlDemoViewModel>();
|
||||
SimpleIoc.Default.Register<ImageBrowserDemoViewModel>();
|
||||
SimpleIoc.Default.Register<ComboBoxDemoViewModel>();
|
||||
SimpleIoc.Default.Register<WindowDemoViewModel>();
|
||||
}
|
||||
|
||||
public static ViewModelLocator Instance => new Lazy<ViewModelLocator>(() =>
|
||||
@@ -30,6 +34,8 @@ namespace HandyControlDemo.ViewModel
|
||||
|
||||
public ComboBoxDemoViewModel ComboBoxDemo => ServiceLocator.Current.GetInstance<ComboBoxDemoViewModel>();
|
||||
|
||||
public WindowDemoViewModel WindowDemo => ServiceLocator.Current.GetInstance<WindowDemoViewModel>();
|
||||
|
||||
#endregion
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
using System;
|
||||
using GalaSoft.MvvmLight.CommandWpf;
|
||||
using HandyControlDemo.Tools;
|
||||
|
||||
namespace HandyControlDemo.ViewModel
|
||||
{
|
||||
public class WindowDemoViewModel
|
||||
{
|
||||
public RelayCommand<string> OpenWindowCmd => new Lazy<RelayCommand<string>>(() => new RelayCommand<string>(OpenWindow)).Value;
|
||||
|
||||
private void OpenWindow(string windowTag)
|
||||
{
|
||||
if (AssemblyHelper.CreateInternalInstance($"Window.{windowTag}") is System.Windows.Window window)
|
||||
{
|
||||
window.ShowDialog();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user