📜 ⬆️ ⬇️

WPF Tipz # 1

Just now my corners broke, no, of course - they broke,
No, thank God, not in life, but only in the application.

The application lived for half a year and at least henna, and here once the corners of it broke.

PS
')
The theme of corners in WPF may not be fully disclosed,
actually your options for implementations are very welcome :)



I thought, puffed, fought with radii and with corners and with thickness and transparency,
nothing came of it ...

Meanwhile, in Visual Studio, everything looked fine:


Unlike the compiled version:


I went to swear at the update of the studio SP1, and in the meantime ask what to do ...
He waited as usual for an answer, but then he realized that maybe the video card was to blame,
recently updated to 9600GT, maybe the Chinese brothers poshamanil ...
Wrote, zero response ...

An hour passed, the brain waking up from activity to passivity was pushing me towards the utility of setting up the Nvidia driver, I went there in the 3D option, so everything is focused on quality ...

After all, it should be the other way around ...

I changed the settings to “Settings according to the 3D application” ...
My corners are lit in blue, I think it is no accident that it recompiled the application and
joy knew no bounds, my corners came back to me :)



PS
I hope my experience will help someone.
Please do not minus me to those people who do not like corners or
WPF or Microsoft or noise on the shores of the Canary Islands.

Pps

Corners Code:

< Window x:Class ="ZabrRssReader.Forms.Windows.ViewFeedItem"
xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x ="http://schemas.microsoft.com/winfx/2006/xaml"

Width ="310" Height ="260" WindowStyle ="None" Background ="Transparent"
AllowsTransparency ="True" WindowStartupLocation ="CenterOwner" >
< Border BorderThickness ="3,5,3,5" CornerRadius ="20,20,20,20" Padding ="10" >

< Border.BorderBrush >
< LinearGradientBrush StartPoint ="0,0" EndPoint ="0,1" >
< GradientStop Color ="#FFAAAAAA" Offset ="0" ></ GradientStop >
< GradientStop Color ="#FFAAAAAA" Offset ="1" ></ GradientStop >
</ LinearGradientBrush >
</ Border.BorderBrush >

< Border.Background >
< LinearGradientBrush StartPoint ="0,0" EndPoint ="0,1" >
< GradientStop Color ="#615B5D" Offset ="0" ></ GradientStop >
< GradientStop Color ="#615B5D" Offset ="0.2" ></ GradientStop >
< GradientStop Color ="#615B5D" Offset ="0.3" ></ GradientStop >
< GradientStop Color ="#615B5D" Offset ="0.2" ></ GradientStop >
< GradientStop Color ="#000000" Offset ="1" ></ GradientStop >
</ LinearGradientBrush >
</ Border.Background >

< TextBlock TextAlignment ="Center" VerticalAlignment ="Center" >
Hello World!
</ TextBlock >
</ Border >
</ Window >
< Window x:Class ="ZabrRssReader.Forms.Windows.ViewFeedItem"
xmlns ="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x ="http://schemas.microsoft.com/winfx/2006/xaml"

Width ="310" Height ="260" WindowStyle ="None" Background ="Transparent"
AllowsTransparency ="True" WindowStartupLocation ="CenterOwner" >
< Border BorderThickness ="3,5,3,5" CornerRadius ="20,20,20,20" Padding ="10" >

< Border.BorderBrush >
< LinearGradientBrush StartPoint ="0,0" EndPoint ="0,1" >
< GradientStop Color ="#FFAAAAAA" Offset ="0" ></ GradientStop >
< GradientStop Color ="#FFAAAAAA" Offset ="1" ></ GradientStop >
</ LinearGradientBrush >
</ Border.BorderBrush >

< Border.Background >
< LinearGradientBrush StartPoint ="0,0" EndPoint ="0,1" >
< GradientStop Color ="#615B5D" Offset ="0" ></ GradientStop >
< GradientStop Color ="#615B5D" Offset ="0.2" ></ GradientStop >
< GradientStop Color ="#615B5D" Offset ="0.3" ></ GradientStop >
< GradientStop Color ="#615B5D" Offset ="0.2" ></ GradientStop >
< GradientStop Color ="#000000" Offset ="1" ></ GradientStop >
</ LinearGradientBrush >
</ Border.Background >

< TextBlock TextAlignment ="Center" VerticalAlignment ="Center" >
Hello World!
</ TextBlock >
</ Border >
</ Window >



================================================= =========

The line makes the corners and thickness of the borders:
< Border BorderThickness = "3,5,3,5" CornerRadius = "20,20,20,20" Padding = "10" >


In order for the corners to be able to “feel” properly, we turn on the transparency in the window:
WindowStyle = "None" Background = "Transparent" AllowsTransparency = "True"

And in order for us to move the mold for the "body parts" add the method
MouseDown = "Window_MouseDown" to the window description line, and add the method to the code file:

// Makes Window Moving
private void Window_MouseDown ( object sender, MouseButtonEventArgs e)
{
if (e.LeftButton == MouseButtonState.Pressed) DragMove ();
}


PPPS

Are you interested in a series of articles in the form of tipzy or a little more academically dry by WPF?

Source: https://habr.com/ru/post/40489/


All Articles