MNie
MNie

Reputation: 1367

Access to the path xaml

I have problem with, access to the path in canvas, I want to be able to changing the 'fill' in my code(c#). These is my xaml code:

<Canvas Name="hour" Opacity="0.05" Grid.Row="2" Grid.Column="1" HorizontalAlignment="Center" VerticalAlignment="Center" Width="0" Height="0" >
    <Path Fill="Aquamarine">
        <Path.Data>
            <EllipseGeometry RadiusX="50" RadiusY="50"/>
        </Path.Data>
    </Path>
</Canvas> 

How to get it?

Upvotes: 0

Views: 52

Answers (1)

har07
har07

Reputation: 89285

Just give it a name:

<Path x:Name="myPath" Fill="Aquamarine">

So you can access it in code, like:

myPath.Fill = new SolidColorBrush(Colors.Blue);

Upvotes: 1

Related Questions