This commit is contained in:
NaBian committed 2020-06-22 00:22:55 +08:00
commit 398e285f3d
36 files changed
+1019 -43

No files matched your search

@@ -0,0 +1,10 @@
namespace HandyControlDemo.UserControl
{
public partial class ImageSelectorDemoCtl
{
public ImageSelectorDemoCtl()
{
InitializeComponent();
}
}
}
@@ -44,7 +44,7 @@
<ColumnDefinition/>
<ColumnDefinition Width="Auto"/>
</Grid.ColumnDefinitions>
<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}"/>
<hc:SearchBar ShowClearButton="True" IsRealTime="True" 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}"/>
<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>
@@ -2,7 +2,6 @@
using System.Windows;
using System.Windows.Controls;
using System.Windows.Controls.Primitives;
using HandyControl.Controls;
using HandyControl.Data;
using HandyControlDemo.Data;
using HandyControlDemo.ViewModel;
@@ -31,6 +30,7 @@ namespace HandyControlDemo.UserControl
var selectedIndex = demoInfo.SelectedIndex;
demoInfo.SelectedIndex = -1;
demoInfo.SelectedIndex = selectedIndex;
FilterItems();
}
}
@@ -52,6 +52,11 @@ namespace HandyControlDemo.UserControl
private void SearchBar_OnSearchStarted(object sender, FunctionEventArgs<string> e)
{
_searchKey = e.Info;
FilterItems();
}
private void FilterItems()
{
if (string.IsNullOrEmpty(_searchKey))
{
foreach (var item in ViewModelLocator.Instance.Main.DemoInfoCurrent.DemoItemList)
@@ -68,7 +73,7 @@ namespace HandyControlDemo.UserControl
{
item.IsVisible = true;
}
else if(item.TargetCtlName.Replace("DemoCtl", "").ToLower().Contains(key))
else if (item.TargetCtlName.Replace("DemoCtl", "").ToLower().Contains(key))
{
item.IsVisible = true;
}
@@ -87,20 +92,5 @@ namespace HandyControlDemo.UserControl
}
}
}
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;
}
}
}
}
}
}