Tạo giao diện Aero Style.

Mã XAML:

<Window x:Class="AeroStyle.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation&quot;
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml&quot;
        Title="MainWindow" Height="350" Width="525" AllowsTransparency="True" BorderThickness="1,1,1,1" WindowStyle="None" MouseDown="Window_Mousedown">
    <Window.BitmapEffect>
        <DropShadowBitmapEffect/>
    </Window.BitmapEffect>
    <Window.Background>
        <LinearGradientBrush StartPoint="0.5,0" EndPoint="0.5,1">
            <GradientStop Color="#4CA2A2A2" Offset="0"/>
            <GradientStop Color="#4CA2A2A2" Offset="1"/>
            <GradientStop Color="#60B4B4B4" Offset="0.246"/>
            <GradientStop Color="#60FFFFFF" Offset="0.42"/>
            <GradientStop Color="#60E7E7E7" Offset="0.67"/>
            <GradientStop Color="#60FFFFFF" Offset="0.835"/>
        </LinearGradientBrush>
    </Window.Background>
</Window>


Đoạn mã sau dùng để tạo bóng đổ:
    <Window.BitmapEffect>

        <DropShadowBitmapEffect/>

    </Window.BitmapEffect>

Sau đó, xử lý event MouseClick của window:


                private void Window_Mousedown(object sender, MouseButtonEventArgs e)
        {
            if (e.LeftButton == MouseButtonState.Pressed)
                this.DragMove();
        }


Cuối cùng, ta được kết quả:

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s