Is there a way to resize controls, such as a button, instantaniously with the window being resized?
Currently, I am using a button click method to resize using this code:

UpdateLayout();
addButton.Height = this.Height / 30;

Recommended Answers

All 5 Replies

thank you.. here is code if anyone in future looks at this and needs help

xaml code in the window ===> SizeChanged="AddInfoToStudyBuddy_Resize"
.cs code:

private void AddInfoToStudyBuddy_Resize(object sender, SizeChangedEventArgs e)
[
addButton.Height = this.Height / 20;
tabControl.Height = this.Height - 150;
tabControl.Width = this.Width - 100;
question.Width = this.Width - 130;
question.Height += this.Height / 30;
]

WARNING. I should have noted this. Be sure to test that "this" dimensions are not zero. That is, what size is this when the app is minimized?

I didn't account for this and my demo crashed when an user did that. I knew what it was but due to the rush to get the demo working (it was a demo) I hadn't coded for this instance.

No worries, It minimizes alright and no issues. I'm guessing it was fixed with later releases

Be sure to test it harder. Grab a corner and make it tiny. Some controls don't like the negativity.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.