Let’s say I have 1 row and 2 columns. Both have a video stream which will automatically resize to fill what it can, so they both take half the screen.
I want to be able to remove one stream and have the second fill the entire screen. So basically, have the second cell push to fill the entire screen since nothing is occupying the first cell to “push it” back.
I know I can do this by removing cells, but it would be many times cleaner, simpler, and easier if there were some setting to accomplish what I am describing.
EDIT:
<Grid.RowDefinitions>
<RowDefinition Height="*"/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*"/>
</Grid.ColumnDefinitions>
I start with only one of each and expand dynamically from there by doing:
if (grd.ColumnDefinitions.Count == grd.RowDefinitions.Count)
{
System.Windows.Controls.ColumnDefinition newColumn;
newColumn = new System.Windows.Controls.ColumnDefinition();
grd.ColumnDefinitions.Add(newColumn);
Column = grd.ColumnDefinitions.Count - 1;
Row = 0;
}
else
{
System.Windows.Controls.RowDefinition newRow;
newRow = new System.Windows.Controls.RowDefinition();
grd.RowDefinitions.Add(newRow);
Row = grd.RowDefinitions.Count - 1;
Column = 0;
}
Try setting the
Widthof theGridViewColumnto0and theVisibilityof the container control (either the view stream control itself or its container) toCollapsed.EDIT
Although a
UniformGridmight be easier to work with. Then you’d only need to set the visibility of the control to collapsed (which will remove that control from the width calculation).I’d recommend setting the UniformGrid’s
Rowsproperty to1to keep everything on a single line (otherwise it will begin a process of alternately adding rows and columns).Use the above code for inspiration. The first video stream control is wrapped in a Grid simply to demonstrate how you might “add” the visibility property if the control you are using does not expose one. It is completely optional.