【问题标题】:How to use margin as property of WPF usercontrol?如何使用边距作为 WPF 用户控件的属性?
【发布时间】:2010-06-18 05:18:14
【问题描述】:

如何使用边距作为 WPF 用户控件的属性?

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

【问题讨论】:

  • 你的问题不够清楚。 UserControls 已经有一个 margin 属性。

标签: c# wpf user-controls inotifypropertychanged


【解决方案1】:

UserControl 有一个 Margin 属性,你可以这样使用它...

设置它:

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

得到它:

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

这是你想知道的吗?

【讨论】:

  • 顺便说一句:后一段代码中 Margin 的初始化是为了什么?
猜你喜欢
  • 1970-01-01
  • 2014-10-07
  • 2021-02-04
  • 2014-08-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多