update demo
This commit is contained in:
1 parent
ea9d6b78cc
commit
e67c04bf82
5 files changed
+70
-10
No files matched your search
@@ -43,6 +43,7 @@
|
|||||||
<a href="https://github.com/yxhq" target="_blank"><img style="border-radius:50%" width="64px" alt="yxhq" src="https://avatars3.githubusercontent.com/u/10378954?s=64&v=4"></a>
|
<a href="https://github.com/yxhq" target="_blank"><img style="border-radius:50%" width="64px" alt="yxhq" src="https://avatars3.githubusercontent.com/u/10378954?s=64&v=4"></a>
|
||||||
<a href="https://github.com/AiHaibara" target="_blank"><img style="border-radius:50%" width="64px" alt="AiHaibara" src="https://avatars3.githubusercontent.com/u/5195234?s=64&v=4"></a>
|
<a href="https://github.com/AiHaibara" target="_blank"><img style="border-radius:50%" width="64px" alt="AiHaibara" src="https://avatars3.githubusercontent.com/u/5195234?s=64&v=4"></a>
|
||||||
<a href="https://github.com/walterlv" target="_blank"><img style="border-radius:50%" width="64px" alt="walterlv" src="https://avatars3.githubusercontent.com/u/9959623?s=64&v=4"></a>
|
<a href="https://github.com/walterlv" target="_blank"><img style="border-radius:50%" width="64px" alt="walterlv" src="https://avatars3.githubusercontent.com/u/9959623?s=64&v=4"></a>
|
||||||
|
<a href="https://github.com/Luoyingliang" target="_blank"><img style="border-radius:50%" width="64px" alt="Luoyingliang" src="https://avatars2.githubusercontent.com/u/29297262?s=64&v=4"></a>
|
||||||
|
|
||||||
## Backers
|
## Backers
|
||||||
|
|
||||||
|
|||||||
@@ -1,6 +1,8 @@
|
|||||||
namespace HandyControlDemo.Data
|
using GalaSoft.MvvmLight;
|
||||||
|
|
||||||
|
namespace HandyControlDemo.Data
|
||||||
{
|
{
|
||||||
public class DemoItemModel
|
public class DemoItemModel : ObservableObject
|
||||||
{
|
{
|
||||||
public string Name { get; set; }
|
public string Name { get; set; }
|
||||||
|
|
||||||
@@ -9,5 +11,17 @@
|
|||||||
public string ImageName { get; set; }
|
public string ImageName { get; set; }
|
||||||
|
|
||||||
public bool IsNew { get; set; }
|
public bool IsNew { get; set; }
|
||||||
|
|
||||||
|
private bool _isVisible = true;
|
||||||
|
|
||||||
|
public bool IsVisible
|
||||||
|
{
|
||||||
|
get => _isVisible;
|
||||||
|
#if NET40
|
||||||
|
set => Set(nameof(IsVisible), ref _isVisible, value);
|
||||||
|
#else
|
||||||
|
set => Set(ref _isVisible, value);
|
||||||
|
#endif
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -40,6 +40,7 @@
|
|||||||
</Style>
|
</Style>
|
||||||
|
|
||||||
<Style x:Key="ListBoxItemTransparent" BasedOn="{StaticResource ListBoxItemBaseStyle}" TargetType="ListBoxItem">
|
<Style x:Key="ListBoxItemTransparent" BasedOn="{StaticResource ListBoxItemBaseStyle}" TargetType="ListBoxItem">
|
||||||
|
<Setter Property="Visibility" Value="{Binding IsVisible,Converter={StaticResource Boolean2VisibilityConverter}}"/>
|
||||||
<Setter Property="hc:BorderElement.CornerRadius" Value="4"/>
|
<Setter Property="hc:BorderElement.CornerRadius" Value="4"/>
|
||||||
<Setter Property="Background" Value="Transparent"/>
|
<Setter Property="Background" Value="Transparent"/>
|
||||||
</Style>
|
</Style>
|
||||||
|
|||||||
@@ -44,7 +44,7 @@
|
|||||||
<ColumnDefinition/>
|
<ColumnDefinition/>
|
||||||
<ColumnDefinition Width="Auto"/>
|
<ColumnDefinition Width="Auto"/>
|
||||||
</Grid.ColumnDefinitions>
|
</Grid.ColumnDefinitions>
|
||||||
<hc:SearchBar SearchStarted="SearchBar_OnSearchStarted" Style="{StaticResource SearchBarPlus}" hc:InfoElement.Placeholder="{ex:Lang Key={x:Static langs:LangKeys.PlsEnterKey}}" Margin="0,4,4,4" Tag="{Binding ElementName=ListBoxDemo}"/>
|
<hc:SearchBar ShowClearButton="True" TextChanged="SearchBar_OnTextChanged" SearchStarted="SearchBar_OnSearchStarted" Style="{StaticResource SearchBarPlus}" hc:InfoElement.Placeholder="{ex:Lang Key={x:Static langs:LangKeys.PlsEnterKey}}" Margin="0,4,4,4" Tag="{Binding ElementName=ListBoxDemo}"/>
|
||||||
<ToggleButton Tag="{Binding ElementName=ListBoxDemo}" Name="ButtonStyleAscending" Click="ButtonAscending_OnClick" Grid.Row="0" Grid.Column="1" Style="{StaticResource DemoInfoSortButtonStyle}"/>
|
<ToggleButton Tag="{Binding ElementName=ListBoxDemo}" Name="ButtonStyleAscending" Click="ButtonAscending_OnClick" Grid.Row="0" Grid.Column="1" Style="{StaticResource DemoInfoSortButtonStyle}"/>
|
||||||
<ListBox Name="ListBoxDemo" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" VirtualizingStackPanel.IsVirtualizing="True" SelectedIndex="{Binding SelectedIndex}" ItemsSource="{Binding DemoItemList}" BorderThickness="0" SelectionMode="Single" Style="{StaticResource ListBoxTransparent}">
|
<ListBox Name="ListBoxDemo" Grid.Column="0" Grid.ColumnSpan="2" Grid.Row="1" VirtualizingStackPanel.IsVirtualizing="True" SelectedIndex="{Binding SelectedIndex}" ItemsSource="{Binding DemoItemList}" BorderThickness="0" SelectionMode="Single" Style="{StaticResource ListBoxTransparent}">
|
||||||
<ListBox.ItemTemplate>
|
<ListBox.ItemTemplate>
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
using System.Windows;
|
using System.Windows;
|
||||||
using System.Windows.Controls;
|
using System.Windows.Controls;
|
||||||
using System.Windows.Controls.Primitives;
|
using System.Windows.Controls.Primitives;
|
||||||
|
using HandyControl.Controls;
|
||||||
using HandyControl.Data;
|
using HandyControl.Data;
|
||||||
using HandyControl.Tools.Extension;
|
|
||||||
using HandyControlDemo.Data;
|
using HandyControlDemo.Data;
|
||||||
using HandyControlDemo.ViewModel;
|
using HandyControlDemo.ViewModel;
|
||||||
|
|
||||||
@@ -15,6 +15,8 @@ namespace HandyControlDemo.UserControl
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
public partial class LeftMainContent
|
public partial class LeftMainContent
|
||||||
{
|
{
|
||||||
|
private string _searchKey;
|
||||||
|
|
||||||
public LeftMainContent()
|
public LeftMainContent()
|
||||||
{
|
{
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
@@ -49,13 +51,55 @@ namespace HandyControlDemo.UserControl
|
|||||||
|
|
||||||
private void SearchBar_OnSearchStarted(object sender, FunctionEventArgs<string> e)
|
private void SearchBar_OnSearchStarted(object sender, FunctionEventArgs<string> e)
|
||||||
{
|
{
|
||||||
if (e.Info == null) return;
|
_searchKey = e.Info;
|
||||||
if (!(sender is FrameworkElement searchBar && searchBar.Tag is ListBox listBox)) return;
|
if (string.IsNullOrEmpty(_searchKey))
|
||||||
foreach (DemoItemModel item in listBox.Items)
|
|
||||||
{
|
{
|
||||||
var listBoxItem = listBox.ItemContainerGenerator.ContainerFromItem(item) as ListBoxItem;
|
foreach (var item in ViewModelLocator.Instance.Main.DemoInfoCurrent.DemoItemList)
|
||||||
listBoxItem?.Show(item.Name.ToLower().Contains(e.Info.ToLower()) ||
|
{
|
||||||
item.TargetCtlName.Replace("DemoCtl", "").ToLower().Contains(e.Info.ToLower()));
|
item.IsVisible = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var key = _searchKey.ToLower();
|
||||||
|
foreach (var item in ViewModelLocator.Instance.Main.DemoInfoCurrent.DemoItemList)
|
||||||
|
{
|
||||||
|
if (item.Name.ToLower().Contains(key))
|
||||||
|
{
|
||||||
|
item.IsVisible = true;
|
||||||
|
}
|
||||||
|
else if(item.TargetCtlName.Replace("DemoCtl", "").ToLower().Contains(key))
|
||||||
|
{
|
||||||
|
item.IsVisible = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
var name = Properties.Langs.LangProvider.GetLang(item.Name);
|
||||||
|
if (!string.IsNullOrEmpty(name) && name.ToLower().Contains(key))
|
||||||
|
{
|
||||||
|
item.IsVisible = true;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
item.IsVisible = false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SearchBar_OnTextChanged(object sender, TextChangedEventArgs e)
|
||||||
|
{
|
||||||
|
if (e.OriginalSource is SearchBar searchBar)
|
||||||
|
{
|
||||||
|
_searchKey = searchBar.Text;
|
||||||
|
if (string.IsNullOrEmpty(_searchKey))
|
||||||
|
{
|
||||||
|
foreach (var item in ViewModelLocator.Instance.Main.DemoInfoCurrent.DemoItemList)
|
||||||
|
{
|
||||||
|
item.IsVisible = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in new issue
Block a user