KnowledgeHub
Questions
Tags
Users
Search
Alex Rivera
|
Logout
Edit Question
Title
Body
This seems like it should be easy but I'm stumped. In WPF, I'd like a TextBox that stretches to the width of it's parent, but only to a maximum width. The problem is that I want it to be left justified within its parent. To get it to stretch you have to use HorizontalAlignment="Stretch", but then the result is centered. I've experimented with HorizontalContentAlignment, but it doesn't seem to do anything. How do I get this blue text box to grow with the size of the window, have a maximum width of 200 pixels, and be left justified? <Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"> <StackPanel> <TextBox Background="Azure" Text="Hello" HorizontalAlignment="Stretch" MaxWidth="200" /> </StackPanel> </Page> What's the trick?
Tags (comma-separated)
Save Edits
Cancel