I have a popup control on a LayoutAware page.
What I really want is for the popup to fill the screen.
I think that the solution is to use Window.Current.Bounds.Height/Width to set the respective properties on a grid inside of the popup control.
I do not want to use the code behind file to set these properties. I would like to be able to bind to Window.Current.Bounds.Height in the XAML.
Can I do this?
Is there a better way to make a popup fill the screen?
You can do it by writing converters for height and width.
public class WidthConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
return Window.Current.Bounds.Width;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
public class HeightConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, string language)
{
return Window.Current.Bounds.Height;
}
public object ConvertBack(object value, Type targetType, object parameter, string language)
{
throw new NotImplementedException();
}
}
Add this in your page resources section -
<common:WidthConverter x:Key="wc" />
<common:HeightConverter x:Key="hc" />
Use them for your popup -
<Popup x:Name="myPopup" >
<Grid Background="#FFE5E5E5" Height="{Binding Converter={StaticResource hc}}" Width="{Binding Converter={StaticResource wc}}" />
</Popup>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With