feat: use repeat button

This commit is contained in:
rabbitism
2024-03-09 21:50:15 +08:00
parent 24dd00d552
commit 93b55aae5e
2 changed files with 16 additions and 19 deletions

View File

@@ -6,66 +6,68 @@
<ControlTheme x:Key="{x:Type u:NumPad}" TargetType="{x:Type u:NumPad}">
<Setter Property="Template">
<ControlTemplate TargetType="u:NumPad">
<Border Padding="48">
<Border>
<Border.Styles>
<Style Selector="Button">
<Style Selector="RepeatButton">
<Setter Property="Command" Value="{Binding $parent[u:NumPad].InputNumber}" />
<Setter Property="CommandParameter" Value="{Binding $self.Content}" />
<Setter Property="Width" Value="48"/>
<Setter Property="Height" Value="48"/>
</Style>
</Border.Styles>
<Grid ColumnDefinitions="*,*,*" RowDefinitions="*,*,*,*">
<Button
<RepeatButton
Grid.Row="0"
Grid.Column="0"
Content="7"
Focusable="False" />
<Button
<RepeatButton
Grid.Row="0"
Grid.Column="1"
Content="8"
Focusable="False" />
<Button
<RepeatButton
Grid.Row="0"
Grid.Column="2"
Content="9"
Focusable="False" />
<Button
<RepeatButton
Grid.Row="1"
Grid.Column="0"
Content="4"
Focusable="False" />
<Button
<RepeatButton
Grid.Row="1"
Grid.Column="1"
Content="5"
Focusable="False" />
<Button
<RepeatButton
Grid.Row="1"
Grid.Column="2"
Content="6"
Focusable="False" />
<Button
<RepeatButton
Grid.Row="2"
Grid.Column="0"
Content="1"
Focusable="False" />
<Button
<RepeatButton
Grid.Row="2"
Grid.Column="1"
Content="2"
Focusable="False" />
<Button
<RepeatButton
Grid.Row="2"
Grid.Column="2"
Content="3"
Focusable="False" />
<Button
<RepeatButton
Grid.Row="3"
Grid.ColumnSpan="2"
Grid.Column="0"
Content="0"
Focusable="False" />
<Button
<RepeatButton
Grid.Row="3"
Grid.Column="2"
Content="."

View File

@@ -60,12 +60,7 @@ public class NumPad: TemplatedControl
return;
}
var numPad = new NumPad() { Target = sender as InputElement };
OverlayDialog.ShowCustom(numPad, new object());
}
protected override void OnApplyTemplate(TemplateAppliedEventArgs e)
{
base.OnApplyTemplate(e);
OverlayDialog.Show(numPad, new object(), options: new OverlayDialogOptions() { Buttons = DialogButton.None });
}
private void OnSevenButtonClick(object sender, RoutedEventArgs e)