简体   繁体   中英

How to use margin as property of WPF usercontrol?

How to use margin as property of WPF usercontrol?

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

UserControl have a Margin Property and you use it like this...

to set it:

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

to get it:

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

Is that what you wanted to know?

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM