views:

61

answers:

3

Still not solved:

I have the following issue:

I have a user control looking like this:

<UserControl x:Class="UserControlSettings"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt;    
<Grid x:Name="mainGrid" ShowGridLines="True">
    <Grid.ColumnDefinitions>
        <ColumnDefinition/>
        <ColumnDefinition/>
    </Grid.ColumnDefinitions>
    <Grid.RowDefinitions>
        <RowDefinition Height="50" />
        <RowDefinition Height="50" />
        <RowDefinition Height="50" />
    </Grid.RowDefinitions>
    <TextBlock Grid.Row="0" Grid.Column="0" FontSize="20">Test</TextBlock>
    <Button Grid.Row="1" Grid.Column="0">Click</Button>
</Grid>

In the designer preview window it looks just fine. I see gridlines, textblock and the button.

When I embed it in a window, I only see the grid lines and no text or button. UserControl is embedded as follows:

<Window x:Class="Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:my="clr-namespace:APP.NET"                    
Title="Window1" Height="300" Width="300">
<Grid>
    <my:UserControlSettings x:Name="controlSettings"/>
</Grid>
</Window>

Any help is appreciated.

A: 

FYI, your row and column definitions are reversed. You are trying to use two rows when you only have one defined.

Dave
Sorry, I there are actually more rows and I stripped one too many before pasting the code. It actually is: <Grid.RowDefinitions> <RowDefinition Height="50" /> <RowDefinition Height="50" /> <RowDefinition Height="50" /> </Grid.RowDefinitions>
Matt
A: 

Other than the mixed up Row/Column settings everything else looks ok with what you posted but without seeing the XAML for the other UserControl I suspect that it is probably being sized so that it takes up the entire 300x300 area of the window. Since controlSettingsPanel is the first item added to the DockPanel it will be given as much space as it needs. As a result, if it takes the entire width of the window the other won't be shown.

John Bowen
But I do see the gridlines, which means the cells are there and not sized to zero. It is just that the TextBlock and the Button are not shown.Also made simpler container window where I just add that one user control (<my:UserControlSettings x:Name="controlSettings"/>). Same thing I only see the gridlines.
Matt
A: 

Your code works absolutely fine for me. Is this all of the code? Are you sure you're not manipulating the controls in code-behind?

There's nothing wrong with the XAML you've posted to make it behave like you described. So it's probably influenced by some other code.

arconaut
That was the right hint. Thanks!
Matt