[TextExtractor] Extend settings with preferred language (#22901)

* [TextExtractor] Extend settings with preferred language

* TextExtractor simplifying code, adding update languages on dropdown opening

* fix typo

* TextExtractor fixing bug with order of languages
This commit is contained in:
Laszlo Nemeth
2022-12-28 19:54:59 +01:00
committed by GitHub
parent 1f4ba8f267
commit dd62dab831
8 changed files with 129 additions and 3 deletions

View File

@@ -55,6 +55,18 @@
MinWidth="{StaticResource SettingActionControlMinWidth}"
HotkeySettings="{x:Bind Path=ViewModel.ActivationShortcut, Mode=TwoWay}" />
</labs:SettingsCard>
<labs:SettingsCard
x:Uid="TextExtractor_Languages">
<ComboBox
x:Name="TextExtractor_ComboBox"
MinWidth="{StaticResource SettingActionControlMinWidth}"
ItemsSource="{x:Bind Path=ViewModel.AvailableLanguages, Mode=OneWay}"
SelectedIndex="{x:Bind Path=ViewModel.LanguageIndex, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"
SelectedValue="{Binding SelectedColorRepresentationValue, Mode=TwoWay}"
Loaded="TextExtractor_ComboBox_Loaded"
DropDownOpened="TextExtractor_ComboBox_DropDownOpened">
</ComboBox>
</labs:SettingsCard>
</controls:SettingsGroup>
</StackPanel>
</controls:SettingsPageControl.ModuleContent>

View File

@@ -23,5 +23,21 @@ namespace Microsoft.PowerToys.Settings.UI.Views
DataContext = ViewModel;
InitializeComponent();
}
private void TextExtractor_ComboBox_Loaded(object sender, Microsoft.UI.Xaml.RoutedEventArgs e)
{
/**
* UWP hack
* because UWP load the bound ItemSource of the ComboBox asynchronous,
* so after InitializeComponent() the ItemSource is still empty and can't automatically select a entry.
* Selection via SelectedItem and SelectedValue is still not working too
*/
ViewModel.UpdateLanguages();
}
private void TextExtractor_ComboBox_DropDownOpened(object sender, object e)
{
ViewModel.UpdateLanguages();
}
}
}