/*-------------------------------------------------------------------------
* 功能描述: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
{
///
/// 宽度支撑
///
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));
///
/// 所支撑的元素
///
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();
}
}
}
}