Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - how to create rounded corners graph (or path)

 
 
Old 08-20-2007   #1 (permalink)
DaberElay


 
 

how to create rounded corners graph (or path)

I'm trying to create a smooth path corners for a graph control using xaml, i
cant seem to find a way through this,

anyone has any idea how to go about it?

thanks!

My System SpecsSystem Spec
Old 08-20-2007   #2 (permalink)
Laurent Bugnion, MVP


 
 

Re: how to create rounded corners graph (or path)

Hi,

DaberElay wrote:
> I'm trying to create a smooth path corners for a graph control using xaml, i
> cant seem to find a way through this,
>
> anyone has any idea how to go about it?
>
> thanks!


When I want to have rounded corners in WPF, I use either a Border panel,
or else I use a Grid and I place a Rectangle as the first child, and
then the other children on top. Then you canalso round the rectangle's
corners.

If you want to use a Path, you can use that Path as a VisualBrush, and
set the Border's background to be that brush.

HTH,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft.ch
PhotoAlbum: http://www.galasoft.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
My System SpecsSystem Spec
Old 08-20-2007   #3 (permalink)
DaberElay


 
 

Re: how to create rounded corners graph (or path)

Hey,

thanks for the prompt answer,

just to get things straight, as i'm very novice to WPF,
rectanges is not what i have in mind, my shapes arbitrary paths, like a
stock graph that goes up and down on a timeline.

I will look into the "Path as a VisualBrush" idea, although i'd love to get
an example of xaml, since i'm not even sure where to start.

in any case thanks for the help,
Nimrod

"Laurent Bugnion, MVP" wrote:

> Hi,
>
> DaberElay wrote:
> > I'm trying to create a smooth path corners for a graph control using xaml, i
> > cant seem to find a way through this,
> >
> > anyone has any idea how to go about it?
> >
> > thanks!

>
> When I want to have rounded corners in WPF, I use either a Border panel,
> or else I use a Grid and I place a Rectangle as the first child, and
> then the other children on top. Then you canalso round the rectangle's
> corners.
>
> If you want to use a Path, you can use that Path as a VisualBrush, and
> set the Border's background to be that brush.
>
> HTH,
> Laurent
> --
> Laurent Bugnion [MVP ASP.NET]
> Software engineering, Blog: http://www.galasoft.ch
> PhotoAlbum: http://www.galasoft.ch/pictures
> Support children in Calcutta: http://www.calcutta-espoir.ch
>

My System SpecsSystem Spec
Old 08-20-2007   #4 (permalink)
Laurent Bugnion, MVP


 
 

Re: how to create rounded corners graph (or path)

Hi,

DaberElay wrote:
> Hey,
>
> thanks for the prompt answer,
>
> just to get things straight, as i'm very novice to WPF,
> rectanges is not what i have in mind, my shapes arbitrary paths, like a
> stock graph that goes up and down on a timeline.
>
> I will look into the "Path as a VisualBrush" idea, although i'd love to get
> an example of xaml, since i'm not even sure where to start.
>
> in any case thanks for the help,
> Nimrod


Here is a quick example I put together in Blend. Disclaimer: I am not a
designer, so it doesn't look great, but you'll get the idea I hope.

<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="WindowsApplication4"
Height="800" Width="800"
AllowsTransparency="True"
WindowStyle="None"
>

<Window.Background>
<VisualBrush>
<VisualBrush.Visual>
<Path
Margin="0,0,0,0"
Stretch="Fill"
Stroke="#FFBA00FF"
StrokeThickness="8"
Data="M0.5,0.5 C-51.000335,-137.32901 357,48.926493
381,0.5 405,-47.926493 786,-74.534251 738.5,0.5 691,75.534251
807.99979,727.96171 738.5,695.5 669.00021,663.03829 -41.000012,757.76307
0.5,695.5 42.000012,633.23693 52.000335,138.32901 0.5,0.5 z">
<Path.Fill>
<LinearGradientBrush EndPoint="1,0.5"
StartPoint="0,0.5">
<GradientStop Color="#FFBA00FF" Offset="0"/>
<GradientStop Color="#FFBA00FF" Offset="1"/>
<GradientStop Color="#FF330046"
Offset="0.659"/>
<GradientStop Color="#FF330046"
Offset="0.479"/>
</LinearGradientBrush>
</Path.Fill>
</Path>
</VisualBrush.Visual>
</VisualBrush>
</Window.Background>


<StackPanel
HorizontalAlignment="Center"
VerticalAlignment="Center"
Width="685" Height="643">

<Label
Content="Hello world"
FontFamily="Algerian"
FontSize="48"
Foreground="#FFF46868"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>

<Label
Content="Hello world"
FontFamily="Broadway"
FontSize="48"
Foreground="#FFA5F468"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>

<Label
Content="Hello world"
FontFamily="Freestyle Script"
FontSize="72"
Foreground="#FF6881F4"
HorizontalAlignment="Center"
VerticalAlignment="Center"/>

</StackPanel>

</Window>

Copy that to XamlPad or KaXaml to see the result.

Greetings,
Laurent
--
Laurent Bugnion [MVP ASP.NET]
Software engineering, Blog: http://www.galasoft.ch
PhotoAlbum: http://www.galasoft.ch/pictures
Support children in Calcutta: http://www.calcutta-espoir.ch
My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Create a path string VB Script
Create Directory on a UNC Path PowerShell
Is there any way to create an absolute/reliable path to a flash drive (name it maybe)? Vista General
Vista - New Crap - Rounded Corners Vista General
Should New-Item consistently create needed path elements? PowerShell


Vista Forums is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media Ltd

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46