Inherit from NavBarItemViewModel and remove duplicate converter
DELETE
WalletWasabi.Fluent/Converters/SearchIconConverter.cs
-using Avalonia;
-using Avalonia.Data.Converters;
-using System;
-using System.Globalization;
-using WalletWasabi.Fluent.ViewModels.Search;
-
-namespace WalletWasabi.Fluent.Converters
-{
- public class SearchIconConverter : IValueConverter
- {
- public static readonly SearchIconConverter Instance = new SearchIconConverter();
-
- private SearchIconConverter()
- {
- }
-
- object? IValueConverter.Convert(object value, Type targetType, object parameter, CultureInfo culture)
- {
- if (value is SearchItemViewModel sivm)
- {
- if (Application.Current.Styles.TryGetResource(sivm.IconName, out object? resource))
- {
- return resource;
- }
- }
-
- return null;
- }
-
- object IValueConverter.ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
- {
- throw new NotImplementedException();
- }
- }
-}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/ViewModels/NavBar/NavBarItemViewModel.cs
WalletWasabi.Fluent/ViewModels/NavBar/NavBarItemViewModel.cs
@@ -45,6 +45,6 @@ namespace WalletWasabi.Fluent.ViewModels.NavBar
set => this.RaiseAndSetIfChanged(ref _isSelected, value);
}
- public ICommand OpenCommand { get; }
+ public ICommand OpenCommand { get; protected set; }
}
}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/ViewModels/Search/SearchItemViewModel.cs
WalletWasabi.Fluent/ViewModels/Search/SearchItemViewModel.cs
using System;
using System.Windows.Input;
using ReactiveUI;
+using WalletWasabi.Fluent.ViewModels.NavBar;
namespace WalletWasabi.Fluent.ViewModels.Search
{
- public class SearchItemViewModel : RoutableViewModel
+ public class SearchItemViewModel : NavBarItemViewModel
{
public SearchItemViewModel(
string title,
@@ -17,18 +18,16 @@ namespace WalletWasabi.Fluent.ViewModels.Search
NavigationTarget navigationTarget,
Func<RoutableViewModel> createTargetView) : base(navigationState, navigationTarget)
{
- IconName = iconName;
Title = title;
Caption = caption;
Order = order;
Category = category;
Keywords = keywords;
+ IconName = iconName;
OpenCommand = ReactiveCommand.Create(() => NavigateTo(createTargetView(), navigationTarget));
}
- public string IconName { get; }
-
- public string Title { get; }
+ public override string IconName { get; }
public string Caption { get; }
@@ -37,7 +36,5 @@ namespace WalletWasabi.Fluent.ViewModels.Search
public SearchCategory Category { get; }
public string Keywords { get; }
-
- public ICommand OpenCommand { get; }
}
}
\ No newline at end of file

MODIFY
WalletWasabi.Fluent/Views/SearchPageView.axaml
WalletWasabi.Fluent/Views/SearchPageView.axaml
<Panel>
<PathIcon Width="20" Height="20" Opacity="0.8" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="12,12,0,0">
<PathIcon.Data>
- <Binding Converter="{x:Static conv:SearchIconConverter.Instance}" />
+ <Binding Converter="{x:Static conv:NavBarIconConverter.Instance}" />
</PathIcon.Data>
</PathIcon>
<TextBlock Text="{Binding Title}" Classes="h7 bold" VerticalAlignment="Top" HorizontalAlignment="Left" Margin="48 13 0 0" />

Inherit from NavBarItemViewModel and remove duplicate converter