EmFeld
EmFeld

Reputation: 227

How to set ScaleTransform ScaleX property value in xaml from xaml.cs

I am dynamically changing the canvas background in my app.

The page.xaml code is:

   <Canvas x:Name="canvasBoard" Height="695" Width="1365" Grid.Row="0">
        <Canvas.Background>
            <ImageBrush Stretch="None" ImageSource="/Assets/board.png"/>
        </Canvas.Background>
        <Canvas.RenderTransform>
            <ScaleTransform ScaleX="1.0"/>
        </Canvas.RenderTransform>
    </Canvas>

I want to change the ScaleTransfom ScaleX value dynamically to the background selected by the page.xaml.cs but am unable to do so. Any help is appreciated.

Upvotes: 1

Views: 3452

Answers (1)

Johan Falk
Johan Falk

Reputation: 4359

If you want to change the value of ScaleX from code which I think is what you are asking you can do that with the following code in page.xaml.cs:

(canvasBoard.RenderTransform as ScaleTransform).ScaleX = 10;

Upvotes: 4

Related Questions