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.
如果你想从代码中改变ScaleX
的值,我认为你可以使用page.xaml.cs
的以下代码来page.xaml.cs
:
(canvasBoard.RenderTransform as ScaleTransform).ScaleX = 10;
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.