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 BPASmartClient.CustomResource.UserControls { /// /// BPABorder.xaml 的交互逻辑 /// public partial class BPABorder : UserControl { public BPABorder() { InitializeComponent(); this.Loaded += (s, o) => { this.canvas.Width = this.ActualWidth; this.canvas.Height = this.ActualHeight; if (this.ActualWidth - 3 >= 0) this.border.Width = this.ActualWidth - 3; if (this.ActualHeight - 3 >= 0) this.border.Height = this.ActualHeight - 3; if (this.ActualWidth - 38 >= 0) { this.TitleBorder.Width = this.ActualWidth - 38; this.bor.Width = this.TitleBorder.Width; } this.bor.Margin = new Thickness(19, 17 + TitleHeight, 0, 0); if (this.ActualHeight - TitleHeight - 21 >= 0) this.bor.Height = this.ActualHeight - TitleHeight - 21; }; } private static void OnPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs s) { (d as BPABorder)?.Refresh(); } private void Refresh() { this.bor.Children.Clear(); this.bor.Children.Add(BackGrid); } public float TitleHeight { get { return (float)GetValue(TitleHeightProperty); } set { SetValue(TitleHeightProperty, value); } } public static readonly DependencyProperty TitleHeightProperty = DependencyProperty.Register("TitleHeight", typeof(float), typeof(BPABorder), new(30.0f)); public string TitleName { get { return (string)GetValue(TitleNameProperty); } set { SetValue(TitleNameProperty, value); } } public static readonly DependencyProperty TitleNameProperty = DependencyProperty.Register("TitleName", typeof(string), typeof(BPABorder), new("标题")); public Panel BackGrid { get { return (Panel)GetValue(BackGridProperty); } set { SetValue(BackGridProperty, value); } } public static readonly DependencyProperty BackGridProperty = DependencyProperty.Register("BackGrid", typeof(Panel), typeof(BPABorder), new PropertyMetadata(default, new PropertyChangedCallback(OnPropertyChanged))); } }