1

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?

Cœur
  • 37,241
  • 25
  • 195
  • 267
Arijit Mukherjee
  • 3,817
  • 2
  • 31
  • 51
  • What about using a Style for your Button? Or does the value for the thickness change dynamically? Phrases like "many buttons similar to this" indicate normally that you want to define a default style(e.g. thickness, margin, ...). Have a look at http://stackoverflow.com/questions/17630968/wpf-c-sharp-button-style?s=2|2.9116 – SSchuette Aug 03 '15 at 05:37
  • No My concept is the button is draggable so when the application is closed the new location should be saved so that the button opens in new location – Arijit Mukherjee Aug 03 '15 at 05:44

1 Answers1

4

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;
Akansha
  • 933
  • 7
  • 18