File tree Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Expand file tree Collapse file tree 2 files changed +22
-2
lines changed Original file line number Diff line number Diff line change 6464 <StackPanel
6565 Width =" 225"
6666 DockPanel.Dock=" Left" >
67- <TextBox Margin =" 8" Watermark =" Search" />
67+ <TextBox Margin =" 8" Watermark =" Search" Text = " {Binding SearchText} " />
6868 <ListBox
69- ItemsSource =" {Binding FileMakerClips }"
69+ ItemsSource =" {Binding FilteredClips }"
7070 SelectedItem =" {Binding SelectedClip}" >
7171 <ListBox .Styles>
7272 <Style Selector =" ListBoxItem" >
Original file line number Diff line number Diff line change @@ -29,13 +29,15 @@ private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
2929 public MainWindowViewModel ( ILogger logger )
3030 {
3131 _logger = logger ;
32+
3233 // default to the local app data folder + \SharpFM, otherwise use provided path
3334 _currentPath ??= Path . Join (
3435 path1 : Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) ,
3536 path2 : Path . Join ( "SharpFM" , "Clips" )
3637 ) ;
3738
3839 FileMakerClips = [ ] ;
40+ FilteredClips = [ ] ;
3941
4042 LoadClips ( CurrentPath ) ;
4143 }
@@ -233,6 +235,8 @@ public static string Version
233235
234236 public ObservableCollection < ClipViewModel > FileMakerClips { get ; set ; }
235237
238+ public ObservableCollection < ClipViewModel > FilteredClips { get ; set ; }
239+
236240 private ClipViewModel ? _selectedClip ;
237241 public ClipViewModel ? SelectedClip
238242 {
@@ -244,6 +248,22 @@ public ClipViewModel? SelectedClip
244248 }
245249 }
246250
251+ private string _searchText = string . Empty ;
252+ public string SearchText
253+ {
254+ get => _searchText ;
255+ set
256+ {
257+ _searchText = value ;
258+ FilteredClips . Clear ( ) ;
259+ foreach ( var c in FileMakerClips . Where ( c => c . Name . Contains ( _searchText ) ) )
260+ {
261+ FilteredClips . Add ( c ) ;
262+ }
263+ NotifyPropertyChanged ( ) ;
264+ }
265+ }
266+
247267 private string _currentPath ;
248268 public string CurrentPath
249269 {
You can’t perform that action at this time.
0 commit comments