微信公众号搜"智元新知"关注
微信扫一扫可直接关注哦!

在C#中具有静态参数的DynamicResource?

如何解决在C#中具有静态参数的DynamicResource?

| 我试图创建一个无边界的WPF应用程序,我发现此代码
<Window
    xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\"
    xmlns:x=\"http://schemas.microsoft.com/winfx/2006/xaml\"
    xmlns:d=\"http://schemas.microsoft.com/expression/blend/2008\" xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" mc:Ignorable=\"d\"
    x:Class=\"VSM.Window2\"
    x:Name=\"Window\"
    Title=\"Window2\"
    Width=\"{DynamicResource {x:Static SystemParameters.MaximizedPrimaryScreenWidthKey}}\" 
    Height=\"{DynamicResource {x:Static SystemParameters.MaximizedPrimaryScreenHeightKey}}\"
    WindowStartupLocation=\"CenterScreen\" AllowsTransparency=\"True\" WindowStyle=\"None\"
    >

    <Grid x:Name=\"LayoutRoot\">
        <Rectangle Fill=\"White\" />
    </Grid>
</Window>
Width=\"{DynamicResource {x:Static SystemParameters.MaximizedPrimaryScreenWidthKey}}\" 
    Height=\"{DynamicResource {x:Static SystemParameters.MaximizedPrimaryScreenHeightKey}}\"
AllowsTransparency=\"True\" WindowStyle=\"None\"
将使用wpf创建无边框窗口应用程序。 我想创建一个按钮,该按钮将运行此最大化应用程序。 与此xaml代码
Width=\"{DynamicResource {x:Static SystemParameters.MaximizedPrimaryScreenWidthKey}}\" 
        Height=\"{DynamicResource {x:Static SystemParameters.MaximizedPrimaryScreenHeightKey}}\"
请帮助我使用dynamicresource bla bla bla到c#将宽度和高度转换为c#,这样我就可以通过编程实现。     

解决方法

        编写代码(在从Window派生的类中):
this.Width = System.Windows.SystemParameters.MaximizedPrimaryScreenWidth;
this.Height = System.Windows.SystemParameters.MaximizedPrimaryScreenHeight;
但是!考虑(取决于您要实现的目标): 应用程序当前显示(您必须导入一些WinAPI函数) SystemParameters.VirtualScreenWidth和SystemParameters.VirtualScreenHeight SystemParameters.FullPrimaryScreenWidth和SystemParameters.FullPrimaryScreenHeight 另请参阅:SystemParameters     

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。