I have a xaml page with 30 togglebuttons on it and I need to bind 4 properties of each togglebutton to a class that I have. I’m able to do the binding, but I’m hoping to find a better solution.
My class currently looks something like this:
public int ToggleButton1Height;
public int ToggleButton1Width;
..
public int ToggleButton2Height;
public int ToggleButton2Width;
..etc
As you can see if I had 4 properties for each togglebutton, that means I need over 120 properties in my class. Is there a better way?
I’m a little curious about your scenario, but here’s the quickest simples solution I can think of. All the code is explained in the comments, but do let me know if you have questions. Of course there’s a ton more solution on how to do this, but I don’t have a lot of details about what are you trying to do. So I hope this works for you. You should be able to just copy paste all this in a new project and have it working.
XAML:
C#: