Tuesday, February 27, 2018

Assistance with Functions to Multiple Elements

C#, WPF, VS2017 https://pasteboard.co/H9AWOlU.jpg

I am working on an application and am having a hard time figuring out how to do something. I attached an image for some clarity. This image is a canvas with multiple textboxes bound to XML data and buttons. The buttons all interact with the textbox DATA and everything is peachy. However, I intend to have 50 of these, and replicating all the button code over and over is not feasible. So I am trying to figure out a universal way to have just a handful of buttons that interact with the selected line/canvas.

I know I can make a class and programatically add the elements to a stack panel. But I am unable to get it look like the image and I really need it to look like that. So I am just poking around to see if anyone has any ideas?

Code Example: (Plus Button in the middle) So this is just 1 of the buttons that interacts with the specific textbox. On the 2nd canvas / monster line it will do the exact same thing, but use the 2nd textbox.

 //Adds 1 HP to Current HP private void m1_plus_MouseUp(object sender, MouseButtonEventArgs e) { Double currenthp; if (m1_chp.Text == "") { MessageBox.Show("Select a Monster First"); } else { currenthp = Convert.ToInt32(m1_chp.Text); int value = Convert.ToInt32(m1_chp.Text); value++; m1_chp.Text = value.ToString(); } } 
Assistance with Functions to Multiple Elements Click here
  • Blogger Comment
  • Facebook Comment

0 comments:

Post a Comment

The webdev Team