Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

Get available space in which the control can expand

$
0
0

I have something like that:

<!-- more controls above --> <Grid Grid.Column="1" Name="grid"><Grid.RowDefinitions><RowDefinition Height="52"/><RowDefinition Height="*"/></Grid.RowDefinitions><ToggleButton Grid.Row="0" HorizontalAlignment="Left" Margin="5,7,0,0" VerticalAlignment="Top" Style="{DynamicResource ToggleButtonExpandResize}" Cursor="Hand"/><!-- INPUT PREVIEW --><MediaElement Margin="5,15,5,15" Grid.Row="1" Name="host" Source="{Binding Source}" LoadedBehavior="Manual" Stretch="Fill"><i:Interaction.Behaviors><mixer:InputPreview /></i:Interaction.Behaviors></MediaElement><!-- more controls below--> 


I need to know the available space of the MediaElement control in the Behavior I've created:

public abstract class BasePreview : Behavior<MediaElement> { protected override void OnAttached() { base.OnAttached(); AssociatedObject.Loaded += Loaded; AssociatedObject.SizeChanged += SizeChanged; } private void SizeChanged(object sender, SizeChangedEventArgs e) {

 if (e.NewSize.IsZero())
                return;

//NEED TO KNOW THE AVAILABLE SPACE OF THE MEDIAELEMENT RIGHT HERE } //more stuff } public class InputPreview : BasePreview {

Why? Because I need to set the Height or Width in order to the MediaElement aspect ratio be 4:3. So, when the MediaElement is Loaded and is filled the entire space, I need to change its size to meet the aspect ratio. In order to do the math involved, I need to know the availabe space (Height and Width) that the MediaElement can fill.

How to get the available space?


Take a look at WPF FlashMessage
About.me



Viewing all articles
Browse latest Browse all 18858

Trending Articles