开发者

Prevent Grid-Column from getting too wide without setting absolute width for child-controls

开发者 https://www.devze.com 2022-12-14 02:52 出处:网络
i have a problem with wpf-grid in .net-framework. I have defined a grid in a UserControl, which cont开发者_JS百科ains a listview, that shows some content. The content of the listview is presented with

i have a problem with wpf-grid in .net-framework. I have defined a grid in a UserControl, which cont开发者_JS百科ains a listview, that shows some content. The content of the listview is presented with DataTemplate and contains a TextBlock which could getting very wide. My grid should separate the UserControl in two 50-50 parts. Both parts should have the same size. If the content in the described TextBlock is small enough there is no Problem. The ListViewItem isn't getting to wide and the columns both taking 50% of the screen. But if the ListViewItem getting more wide, the first column of the grid getting the width of the listviewitem. I know that this could be prevented with MaxWidth, but the problem is that MaxWidth is an absolute value and i get a whitespace if the column is wider.

Is there a way to set MaxWidth to a relative property, that i don't get a too wide column?

My current Column-Definitions are:

<Grid.ColumnDefinitions>
    <ColumnDefinition Width="200*" />
    <ColumnDefinition Width="200*" />
</Grid.ColumnDefinitions>

Would be nice if there are any advices,

Thanks, Greetings, Martin


Hai martin, WPF: Setting the Width (and Height) as a Percentage Value Have a look at this ,it is similar to ur prob

Allow TextBox to be resized but not to grow on user input


Hai martin,

Try setting minimum width property to gridcoloumn defn...

0

精彩评论

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

关注公众号