using PDF_Master.ViewModels.Form; using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Threading.Tasks; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace PDF_Master.Views.Form { /// /// FormsToolContent.xaml 的交互逻辑 /// public partial class FormsToolContent : UserControl { private FormsToolContentViewModel ViewModel =>DataContext as FormsToolContentViewModel; public FormsToolContent() { InitializeComponent(); } private void BtnAlignment_Click(object sender, RoutedEventArgs e) { MenuAlignment.PlacementTarget = this.BtnAlignment; MenuAlignment.IsOpen = true; } /// /// 取消右键弹出下拉菜单 /// /// /// private void BtnAlignment_Initialized(object sender, EventArgs e) { //取消右键菜单的绑定,只能左键点击弹出 this.BtnAlignment.ContextMenu = null; } private void BtnMore_Click(object sender, RoutedEventArgs e) { MenuMore.PlacementTarget = this.BtnMore; MenuMore.IsOpen = true; } private void BtnMore_Initialized(object sender, EventArgs e) { //取消右键菜单的绑定,只能左键点击弹出 this.BtnMore.ContextMenu = null; } private void UserControl_Loaded(object sender, RoutedEventArgs e) { if(ViewModel != null) { ViewModel.UncheckedToolsBtnEvent -= ViewModel_UncheckedToolsBtnEvent; ViewModel.UncheckedToolsBtnEvent += ViewModel_UncheckedToolsBtnEvent; } } private void ViewModel_UncheckedToolsBtnEvent(object sender, string e) { foreach(var item in PnlTool.Children) { var btn = item as RadioButton; if (btn != null) { if (btn.IsChecked == true) { btn.IsChecked = false; break; } } } } private void UserControl_Unloaded(object sender, RoutedEventArgs e) { if (ViewModel != null) { ViewModel.UncheckedToolsBtnEvent -= ViewModel_UncheckedToolsBtnEvent; } } } }