chore: remove topmost view int viewmodel

dev_ocr_translate
DESKTOP-3BO4HSG\ksat 2 years ago
parent 1ac7c152e2
commit 5c76a1df83

@ -46,7 +46,8 @@
Key="T"
Command="{Binding TopmostCmd}"/>
<KeyBinding Key="Esc"
Command="{Binding EscCmd}"/>
Command="{Binding EscCmd}"
CommandParameter="{Binding ElementName=TopmostBtn, Mode=OneWay}"/>
</Window.InputBindings>
@ -80,6 +81,7 @@
<Grid x:Name="Header">
<Button x:Name="TopmostBtn"
Command="{Binding TopmostCmd}"
CommandParameter="{Binding Mode=OneWay, RelativeSource={RelativeSource Self}}"
Template="{DynamicResource ButtonTemplateUnTopmost}"/>
<Button Width="auto"
Template="{DynamicResource ButtonTemplateTheme}"

@ -61,33 +61,31 @@ namespace STranslate.ViewModel
});
//置顶
TopmostCmd = new RelayCommand((_) => true, (_) =>
TopmostCmd = new RelayCommand((_) => true, (o) =>
{
var button = o as System.Windows.Controls.Button;
if (IsTopmost)
{
(Mainwin.FindName("TopmostBtn") as System.Windows.Controls.Button)
.SetResourceReference(System.Windows.Controls.Control.TemplateProperty, _UnTopmostTemplateName);
button.SetResourceReference(System.Windows.Controls.Control.TemplateProperty, _UnTopmostTemplateName);
}
else
{
(Mainwin.FindName("TopmostBtn") as System.Windows.Controls.Button)
.SetResourceReference(System.Windows.Controls.Control.TemplateProperty, _TopmostTemplateName);
button.SetResourceReference(System.Windows.Controls.Control.TemplateProperty, _TopmostTemplateName);
}
IsTopmost = !IsTopmost;
});
//ESC
EscCmd = new RelayCommand((_) => true, (_) =>
EscCmd = new RelayCommand((_) => true, (o) =>
{
Mainwin.Hide();
//取消置顶
if (IsTopmost)
{
(Mainwin.FindName("TopmostBtn") as System.Windows.Controls.Button)
(o as System.Windows.Controls.Button)
.SetResourceReference(System.Windows.Controls.Control.TemplateProperty, _UnTopmostTemplateName);
IsTopmost = !IsTopmost;
}
Mainwin.Hide();
});
//切换语言

Loading…
Cancel
Save