开发者

C# & WPF : How to update an in-code declared textbox height on textbox content change?

开发者 https://www.devze.com 2023-01-20 08:17 出处:网络
I\'m fairly new to C#, I\'m on a C# & Wpf course. Here my teacher has told us to inherit from UserControls and create a wpf control library of our own. In order for us to create a simple UML Edito

I'm fairly new to C#, I'm on a C# & Wpf course. Here my teacher has told us to inherit from UserControls and create a wpf control library of our own. In order for us to create a simple UML Editor, and right now I'm working on a Class Control.

The visual representation of a class as seen here: http://www.softwarefactories.com/ScreenShots/CD-1.JPG

Now, to make things easy for the end user and me as the developer, the fields contained in the class control contain editable textboxes. The fields can dynamically be added to the control, for instance if the class doesn't have any member variables, it won't need a "property" field, and if the user would like to add a "description", he/she may do so easily.

That part is done, but right now the TextBoxes don't adapt in size when edited; the user can add a line, but it won't resize the textbox.开发者_如何转开发

What I want to do is to create an eventhandler of some sort, and have a function run whenever the user changes the content of the textbox.

-How is this done?


Yes, you were absolutely right it's just that I handled the layout wrong further up in the code. Anyway, it uses only a constant set of textboxes, so i just defined those in xml and set the height to auto like it should be. In a stackpanel, they align neatly on top of oneanother. Thanks for your help, dnr3!

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号