Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bug with RowCount="1" #6

Open
Dvornik opened this issue Mar 11, 2016 · 4 comments
Open

Bug with RowCount="1" #6

Dvornik opened this issue Mar 11, 2016 · 4 comments
Labels

Comments

@Dvornik
Copy link

Dvornik commented Mar 11, 2016

Bug with RowCount="1":

<wpfAutoGrid:AutoGrid RowCount="1" Columns="60,*">
    <Label Content="TEST" />
    <TextBox/>
</wpfAutoGrid:AutoGrid>

Result is strange:
9xmf6
No Label and TextBox's width doesn't stretch.

But with this code:

<wpfAutoGrid:AutoGrid RowCount="2" Columns="60,*">
    <Label Content="TEST" />
    <TextBox/>
</wpfAutoGrid:AutoGrid>

Result is OK:
jyc6n

P.S. I really like you container. Thank you very much.

@carbonrobot
Copy link
Owner

Good catch, not sure what is going on here. Looks like its placing all elements in the first row and first column.

@Dvornik
Copy link
Author

Dvornik commented Mar 26, 2016

Looks like its placing all elements in the first row and first column.

Yes. Exactly.

@zspitz
Copy link

zspitz commented Mar 12, 2019

RowCountChanged is not getting called for the default value, in this case 1. Therefore there are no row definitions, and PerformLayout returns early.

@boatschl
Copy link

Quickly jumping in here, as I had the same problem and there hasn't been anything done in 3 years.
The problem is that RowCount and ColumnCount are initially 1 (in dep. prop), but the underlying Grid's RowDefinitions and ColumnDefinitions never get that memo and the PerformLayout() method therefore exits early.

To fix this I added a constructor like this (it's not the most elegant solution but gets the job done):
public AutoGrid() : base() { Debug.Assert(ColumnDefinitions.Count == 0 && RowDefinitions.Count == 0); ColumnDefinitions.Add(new ColumnDefinition() { Width = GridLength.Auto }); RowDefinitions.Add(new RowDefinition() { Height = GridLength.Auto }); }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants