Converters updated as MarkupExtension
This commit is contained in:
@@ -3,11 +3,15 @@ using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Microsoft.UI.Xaml.Controls;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using Microsoft.UI.Xaml.Markup;
|
||||
|
||||
namespace WinWARP.Ui.Converters;
|
||||
|
||||
public class ItemInvokedEventArgsConverter : IValueConverter
|
||||
[MarkupExtensionReturnType(ReturnType = typeof(IValueConverter))]
|
||||
public class ItemInvokedEventArgsConverter : MarkupExtension, IValueConverter
|
||||
{
|
||||
protected override object ProvideValue() => this;
|
||||
|
||||
public object? Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
if (value is NavigationViewItemInvokedEventArgs args)
|
||||
|
||||
@@ -3,11 +3,15 @@ using System.Collections.Generic;
|
||||
using System.Globalization;
|
||||
using System.Text;
|
||||
using Microsoft.UI.Xaml.Data;
|
||||
using Microsoft.UI.Xaml.Markup;
|
||||
|
||||
namespace WinWARP.Ui.Converters;
|
||||
|
||||
public class LanguageCodeToNameConverter : IValueConverter
|
||||
[MarkupExtensionReturnType(ReturnType = typeof(IValueConverter))]
|
||||
public class LanguageCodeToNameConverter : MarkupExtension, IValueConverter
|
||||
{
|
||||
protected override object ProvideValue() => this;
|
||||
|
||||
public object Convert(object value, Type targetType, object parameter, string language)
|
||||
{
|
||||
if (value is string languageCode && !string.IsNullOrWhiteSpace(languageCode))
|
||||
|
||||
@@ -20,9 +20,6 @@
|
||||
</Window.SystemBackdrop>
|
||||
|
||||
<Grid x:Name="RootGrid">
|
||||
<Grid.Resources>
|
||||
<conv:ItemInvokedEventArgsConverter x:Key="ItemInvokedEventArgsConverter" />
|
||||
</Grid.Resources>
|
||||
<Grid.RowDefinitions>
|
||||
<RowDefinition Height="Auto"/>
|
||||
<RowDefinition Height="*"/>
|
||||
@@ -47,7 +44,7 @@
|
||||
<i:EventTriggerBehavior EventName="ItemInvoked">
|
||||
<i:InvokeCommandAction
|
||||
Command="{x:Bind ViewModel.NavigateCommand}"
|
||||
InputConverter="{StaticResource ItemInvokedEventArgsConverter}" />
|
||||
InputConverter="{conv:ItemInvokedEventArgsConverter}" />
|
||||
</i:EventTriggerBehavior>
|
||||
</i:Interaction.Behaviors>
|
||||
<NavigationView.MenuItems>
|
||||
|
||||
@@ -15,9 +15,6 @@
|
||||
|
||||
<ScrollView>
|
||||
<StackPanel Margin="24,14,24,24">
|
||||
<StackPanel.Resources>
|
||||
<conv:LanguageCodeToNameConverter x:Key="LanguageCodeToNameConverter" />
|
||||
</StackPanel.Resources>
|
||||
<TextBlock u:Uids.Uid="SettingsPageTitle" Style="{StaticResource TitleTextBlockStyle}" Margin="0,0,0,10"/>
|
||||
|
||||
<!--App settings-->
|
||||
@@ -67,7 +64,7 @@
|
||||
<ComboBox ItemsSource="{x:Bind ViewModel.Languages}" SelectedItem="{x:Bind ViewModel.SelectedLanguage, Mode=TwoWay}">
|
||||
<ComboBox.ItemTemplate>
|
||||
<DataTemplate x:DataType="x:String">
|
||||
<TextBlock Text="{Binding Converter={StaticResource LanguageCodeToNameConverter}}"/>
|
||||
<TextBlock Text="{Binding Converter={conv:LanguageCodeToNameConverter}}"/>
|
||||
</DataTemplate>
|
||||
</ComboBox.ItemTemplate>
|
||||
</ComboBox>
|
||||
|
||||
Reference in New Issue
Block a user