开发者

DynamicResource With Static Parameter in C#?

Iam trying to create a borderless wpf application and i f开发者_如何学运维ind this code

<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>

with

Width="{DynamicResource {x:Static SystemParameters.MaximizedPrimaryScreenWidthKey}}" 
    Height="{DynamicResource {x:Static SystemParameters.MaximizedPrimaryScreenHeightKey}}"
AllowsTransparency="True" WindowStyle="None"

will create e border less window application with wpf. i want create a button and that button will run this maximize the application. with this xaml code :

Width="{DynamicResource {x:Static SystemParameters.MaximizedPrimaryScreenWidthKey}}" 
        Height="{DynamicResource {x:Static SystemParameters.MaximizedPrimaryScreenHeightKey}}"

please help me convert the width and Height using dynamicresource bla bla bla to c#, so i can do that programmically.


Write the code (in your class derived from Window):

this.Width = System.Windows.SystemParameters.MaximizedPrimaryScreenWidth;
this.Height = System.Windows.SystemParameters.MaximizedPrimaryScreenHeight;

BUT !!! consider (depends on what you want to achieve):

  • current display the application is on (you'll have to import some WinAPI functions)
  • SystemParameters.VirtualScreenWidth and SystemParameters.VirtualScreenHeight
  • SystemParameters.FullPrimaryScreenWidth and SystemParameters.FullPrimaryScreenHeight

See also: SystemParameters

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜