Rob*_*ert 4 xaml microsoft-metro windows-runtime winrt-xaml
我在LayoutAware页面上有一个弹出控件.
我真正想要的是弹出窗口填满屏幕.
我认为解决方案是使用Window.Current.Bounds.Height/Width来设置弹出控件内部网格上的相应属性.
我不想使用代码隐藏文件来设置这些属性.我希望能够绑定到XAML中的Window.Current.Bounds.Height.
我可以这样做吗?
有没有更好的方法让弹出窗口填满屏幕?
你可以通过编写高度和宽度的转换器来实现.
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();
}
}
Run Code Online (Sandbox Code Playgroud)
在页面资源部分添加此内容 -
<common:WidthConverter x:Key="wc" />
<common:HeightConverter x:Key="hc" />
Run Code Online (Sandbox Code Playgroud)
用它们弹出 -
<Popup x:Name="myPopup" >
<Grid Background="#FFE5E5E5" Height="{Binding Converter={StaticResource hc}}" Width="{Binding Converter={StaticResource wc}}" />
</Popup>
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
3587 次 |
| 最近记录: |