如何使用margin作为WPF usercontrol的属性?

时间:2010-06-18 05:18:14

标签: c# wpf user-controls inotifypropertychanged

如何使用margin作为WPF usercontrol的属性?

    public Double pCusSPAge
    {
        get
        {
            return btnCusSPAge.Margin.Left;
        }
        set
        {
            btnCusSPAge.Margin = new Thickness(value);
            if (PropertyChanged != null)
                PropertyChanged(this, new PropertyChangedEventArgs("pCusSPAge"));
        }
    }

1 个答案:

答案 0 :(得分:1)

UserControl有一个Margin Property,你就像这样使用它......

设置它:

        Thickness newMargin = new Thickness(1, 1, 1, 1); //just an example
        UserControl.Margin = newMargin;

得到它:

        Thickness newMargin = new Thickness(); 
        newMargin = UserControl.Margin;

那是你想知道的吗?