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

Grid doesn't work as expected in MasterDetailsView templates #938

Closed
ghost opened this issue Feb 14, 2017 · 2 comments
Closed

Grid doesn't work as expected in MasterDetailsView templates #938

ghost opened this issue Feb 14, 2017 · 2 comments

Comments

@ghost
Copy link

ghost commented Feb 14, 2017

When creating a grid in the ItemTemplate or the DetailsTemplate of the MasterDetailsView, it does not work as expected. Consider this example based on the SampleApp.

 <controls:MasterDetailsView.ItemTemplate>
        <DataTemplate>
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*" />
                    <ColumnDefinition Width="Auto" />
                </Grid.ColumnDefinitions>
                <StackPanel Grid.Column="0">
                    <TextBlock Text="Testing" />
                    <TextBlock Text="Testing again" />
                </StackPanel>
                <Button Content="TestButton" Grid.Column="1" />
            </Grid>
        </DataTemplate>
</controls:MasterDetailsView.ItemTemplate>

Expected behaviour of the first column is to stretch (indicated with Width="*") to the next column. However, this does not work in the ItemTemplate/DetailsTemplate: the Button is placed immediately after the first column, whose width is based on its child item with the highest width.

The same appears to occur with RowDefinitions and Height.

@skendrot
Copy link
Contributor

The MasterDetailsView does use a ListView for the Master portion. The behavior you are experiencing is the default behavior for a ListView. You can override this by modifying the style of the ListViewItem within your page.
Example:

<controls:MasterDetailsView.Resources>
    <Style TargetType="ListViewItem">
        <Setter Property="HorizontalContentAlignment" Value="Stretch"/>
    </Style>
</controls:MasterDetailsView.Resources>

As far as the DetailsTemplate is concerned, I cannot reproduce. The content should stretch.

@ghost
Copy link
Author

ghost commented Feb 15, 2017

@skendrot Thank you very much. Modifying the style of the ListViewItem resolved my issue. I used another custom control (also using ListView) of my own before and never had this issue, but I guess somewhere I did set that style manually as well.

Regarding the DetailsTemplate, I looked again with a fresh mind and the cause was a property on the grid which I had overlooked a lot of times trying to analyse the cause. Whoops... I'll close this issue now :-).

@ghost ghost closed this as completed Feb 15, 2017
@ghost ghost locked as resolved and limited conversation to collaborators Jun 1, 2021
This issue was closed.
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant