Make channel selection input more responsive

This commit is contained in:
pizzaboxer 2023-07-15 17:52:59 +01:00
parent f553a812cb
commit 0162dbf3bb
No known key found for this signature in database
GPG Key ID: 59D4A1DBAD0F2BA8
2 changed files with 1 additions and 17 deletions

View File

@ -42,7 +42,7 @@
<TextBlock FontSize="14" Text="Channel" />
<TextBlock Margin="0,2,0,0" FontSize="12" Text="Choose which deployment channel Roblox should be downloaded from." Foreground="{DynamicResource TextFillColorTertiaryBrush}" />
</StackPanel>
<ComboBox Grid.Column="1" Margin="8,0,8,0" Padding="10,5,10,5" Width="200" IsEditable="True" ItemsSource="{Binding Channels, Mode=OneWay}" Text="{Binding SelectedChannel, Mode=TwoWay, UpdateSourceTrigger=LostFocus}" KeyUp="ComboBox_KeyEnterUpdate" />
<ComboBox Grid.Column="1" Margin="8,0,8,0" Padding="10,5,10,5" Width="200" IsEditable="True" ItemsSource="{Binding Channels, Mode=OneWay}" Text="{Binding SelectedChannel, Mode=TwoWay, Delay=250}" />
</Grid>
</ui:CardExpander.Header>
<StackPanel>

View File

@ -17,21 +17,5 @@ namespace Bloxstrap.UI.Menu.Pages
DataContext = new BehaviourViewModel();
InitializeComponent();
}
// https://stackoverflow.com/a/13289118/11852173
// yes this doesnt fully conform to xaml but whatever
private void ComboBox_KeyEnterUpdate(object sender, KeyEventArgs e)
{
if (e.Key == Key.Enter)
{
ComboBox box = (ComboBox)sender;
DependencyProperty prop = ComboBox.TextProperty;
BindingExpression binding = BindingOperations.GetBindingExpression(box, prop);
if (binding is not null)
binding.UpdateSource();
}
}
}
}