Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 如何使用margin作为wpfusercontrol的属性?_C#_Wpf_User Controls_Inotifypropertychanged - Fatal编程技术网

C# 如何使用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 !

如何使用margin作为wpfusercontrol的属性

    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初始化是为了什么?