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 64
64
<StackPanel
65
65
Width =" 225"
66
66
DockPanel.Dock=" Left" >
67
- <TextBox Margin =" 8" Watermark =" Search" />
67
+ <TextBox Margin =" 8" Watermark =" Search" Text = " {Binding SearchText} " />
68
68
<ListBox
69
- ItemsSource =" {Binding FileMakerClips }"
69
+ ItemsSource =" {Binding FilteredClips }"
70
70
SelectedItem =" {Binding SelectedClip}" >
71
71
<ListBox .Styles>
72
72
<Style Selector =" ListBoxItem" >
Original file line number Diff line number Diff line change @@ -29,13 +29,15 @@ private void NotifyPropertyChanged([CallerMemberName] string propertyName = "")
29
29
public MainWindowViewModel ( ILogger logger )
30
30
{
31
31
_logger = logger ;
32
+
32
33
// default to the local app data folder + \SharpFM, otherwise use provided path
33
34
_currentPath ??= Path . Join (
34
35
path1 : Environment . GetFolderPath ( Environment . SpecialFolder . LocalApplicationData ) ,
35
36
path2 : Path . Join ( "SharpFM" , "Clips" )
36
37
) ;
37
38
38
39
FileMakerClips = [ ] ;
40
+ FilteredClips = [ ] ;
39
41
40
42
LoadClips ( CurrentPath ) ;
41
43
}
@@ -233,6 +235,8 @@ public static string Version
233
235
234
236
public ObservableCollection < ClipViewModel > FileMakerClips { get ; set ; }
235
237
238
+ public ObservableCollection < ClipViewModel > FilteredClips { get ; set ; }
239
+
236
240
private ClipViewModel ? _selectedClip ;
237
241
public ClipViewModel ? SelectedClip
238
242
{
@@ -244,6 +248,22 @@ public ClipViewModel? SelectedClip
244
248
}
245
249
}
246
250
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
+
247
267
private string _currentPath ;
248
268
public string CurrentPath
249
269
{
You can’t perform that action at this time.
0 commit comments