MediaElement inside border RRS feed

  • Question

  • I have a grid as my outermost element and in one of the rows I have a border element and then a media element. The media element fills to the size of the grid row. What do I need to set to ensure the media element stays inside the border?

    <Border Height="Auto" Width="Auto" Margin="10,10,10,10" Padding="5,5,5,5" Grid.Row="1" Grid.Column="0">
    Tuesday, January 20, 2009 8:56 PM

All replies

  • Is your media element bigger than your border? If you have an explicitly set size (say 720x480), and your border is either smaller than that size or can collapse to smaller than that size, you're going to be in trouble.

    If that's the case, you can either set min height and min width attributes to your border that are equal to the media element's size + the border padding, or you can wrap the media element in a scroll viewer to contain it within the border size.
    • Proposed as answer by VLTII Tuesday, January 20, 2009 10:36 PM
    Tuesday, January 20, 2009 10:36 PM
  • The MediaElement has:

    It doesn't have width or height set.
    Tuesday, January 20, 2009 10:56 PM
  • Heh, I just built this in Blend and can't beleive I missed this. You need to set the Border's Grid Row Span to 1. I've attached some xaml that should help.

    <Grid Margin="10,10,10,10" Background="#FFC4C4C4">  
                    <RowDefinition Height="0.233*"/>  
                    <RowDefinition Height="0.767*"/>  
                <Border Padding="5,5,5,5" Margin="10,10,10,10" Background="#FF2E2E2E" Grid.RowSpan="1">  
    Wednesday, January 21, 2009 2:58 PM
  •  Grid.RowSpan was already set to 1. I copied just the grid, border, and media element to a new window and all is good. There must be something else going on with the rest of my xaml.

    Thank you for your assistance.
    Wednesday, January 21, 2009 8:17 PM