123456789101112131415161718192021222324252627282930313233343536373839404142434445464748 |
- /*-------------------------------------------------------------------------
- * 功能描述:WidthSupport
- * 作者:xulisong
- * 创建时间: 2019/5/29 14:24:11
- * 版本号:v1.0
- * -------------------------------------------------------------------------*/
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using System.Threading.Tasks;
- using System.Windows;
- using System.Windows.Controls;
- namespace FWindSoft.Wpf.Controls
- {
- /// <summary>
- /// 宽度支撑
- /// </summary>
- public class WidthSupport:Border
- {
- public WidthSupport()
- {
- this.Visibility = Visibility.Hidden;
- this.HorizontalAlignment = HorizontalAlignment.Stretch;
- }
- public static readonly DependencyProperty MarkerProperty =
- DependencyProperty.Register("SupportElement", typeof(FrameworkElement), typeof(WidthSupport));
- /// <summary>
- /// 所支撑的元素
- /// </summary>
- public FrameworkElement SupportElement
- {
- get { return (FrameworkElement)GetValue(MarkerProperty); }
- set { SetValue(MarkerProperty, value); }
- }
- protected override void OnRenderSizeChanged(SizeChangedInfo sizeInfo)
- {
- //基类是程序集级别的,也能重写?
- if (SupportElement != null)
- {
- (SupportElement).Width = this.ActualWidth;
- SupportElement.UpdateLayout();
- }
- }
- }
- }
|