Reputation: 3875
I have a property as: Button1 System.Windows.Thickness 10,10,10,10
and a Button Name is Button1
. I'm able to set the same as
Propertis.Setting.Default.Button1 = _margin;
I have like many buttons similar to this where my xaml name n property name is the same, so what I want is to set the margin as dynamically
Button option = sender as Button;
Properties.Settings.Default.option = _margin;
Is it achievable? If so How?
Upvotes: 1
Views: 687
Reputation: 943
As the values stored in Settings are key value pairs, you can set any property which has the same name as of Button control as
Button option = sender as Button;
Properties.Settings.Default[option.Name] = _margin;
Upvotes: 4