C# 如何使用margin作为wpfusercontrol的属性?
如何使用margin作为wpfusercontrol的属性C# 如何使用margin作为wpfusercontrol的属性?,c#,wpf,user-controls,inotifypropertychanged,C#,Wpf,User Controls,Inotifypropertychanged,如何使用margin作为wpfusercontrol的属性 public Double pCusSPAge { get { return btnCusSPAge.Margin.Left; } set { btnCusSPAge.Margin = new Thickness(value); if (PropertyChanged !
public Double pCusSPAge
{
get
{
return btnCusSPAge.Margin.Left;
}
set
{
btnCusSPAge.Margin = new Thickness(value);
if (PropertyChanged != null)
PropertyChanged(this, new PropertyChangedEventArgs("pCusSPAge"));
}
}
UserControl有一个边距属性,您可以这样使用它 要设置它,请执行以下操作:
Thickness newMargin = new Thickness(1, 1, 1, 1); //just an example
UserControl.Margin = newMargin;
要获得它:
Thickness newMargin = new Thickness();
newMargin = UserControl.Margin;
这就是你想知道的吗?你的问题不够清楚。UserControls已经有了margin属性。顺便问一下:后一段代码中的margin初始化是为了什么?