File tree Expand file tree Collapse file tree 1 file changed +20
-1
lines changed
src/Files.App/Actions/Global Expand file tree Collapse file tree 1 file changed +20
-1
lines changed Original file line number Diff line number Diff line change @@ -23,16 +23,35 @@ public HotKey SecondHotKey
23
23
public RichGlyph Glyph
24
24
=> new ( themedIconStyle : "App.ThemedIcons.Omnibar.Search" ) ;
25
25
26
+ public bool IsExecutable
27
+ => context . ShellPage is not null ;
28
+
26
29
public SearchAction ( )
27
30
{
28
31
context = Ioc . Default . GetRequiredService < IContentPageContext > ( ) ;
32
+
33
+ context . PropertyChanged += Context_PropertyChanged ;
29
34
}
30
35
31
36
public Task ExecuteAsync ( object ? parameter = null )
32
37
{
33
- context . ShellPage ! . ToolbarViewModel . SwitchToSearchMode ( ) ;
38
+ // Check if ShellPage is available before executing the action
39
+ if ( context . ShellPage is null )
40
+ return Task . CompletedTask ;
41
+
42
+ context . ShellPage . ToolbarViewModel . SwitchToSearchMode ( ) ;
34
43
35
44
return Task . CompletedTask ;
36
45
}
46
+
47
+ private void Context_PropertyChanged ( object ? sender , PropertyChangedEventArgs e )
48
+ {
49
+ switch ( e . PropertyName )
50
+ {
51
+ case nameof ( IContentPageContext . ShellPage ) :
52
+ OnPropertyChanged ( nameof ( IsExecutable ) ) ;
53
+ break ;
54
+ }
55
+ }
37
56
}
38
57
}
You can’t perform that action at this time.
0 commit comments