Note that there are some explanatory texts on larger screens.

plurals
  1. POWhere is the Application.DoEvents() in WPF?
    primarykey
    data
    text
    <p>I have the following sample code that zooms each time a button is pressed:</p> <p>XAML:</p> <pre><code>&lt;Window x:Class="WpfApplication12.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="350" Width="525"&gt; &lt;Canvas x:Name="myCanvas"&gt; &lt;Canvas.LayoutTransform&gt; &lt;ScaleTransform x:Name="myScaleTransform" /&gt; &lt;/Canvas.LayoutTransform&gt; &lt;Button Content="Button" Name="myButton" Canvas.Left="50" Canvas.Top="50" Click="myButton_Click" /&gt; &lt;/Canvas&gt; &lt;/Window&gt; </code></pre> <p>*.cs</p> <pre><code>public partial class MainWindow : Window { public MainWindow() { InitializeComponent(); } private void myButton_Click(object sender, RoutedEventArgs e) { Console.WriteLine("scale {0}, location: {1}", myScaleTransform.ScaleX, myCanvas.PointToScreen(GetMyByttonLocation())); myScaleTransform.ScaleX = myScaleTransform.ScaleY = myScaleTransform.ScaleX + 1; Console.WriteLine("scale {0}, location: {1}", myScaleTransform.ScaleX, myCanvas.PointToScreen(GetMyByttonLocation())); } private Point GetMyByttonLocation() { return new Point( Canvas.GetLeft(myButton), Canvas.GetTop(myButton)); } } </code></pre> <p>the output is:</p> <pre><code>scale 1, location: 296;315 scale 2, location: 296;315 scale 2, location: 346;365 scale 3, location: 346;365 scale 3, location: 396;415 scale 4, location: 396;415 </code></pre> <p>as you can see, there is a problem, that I thought solve by using <code>Application.DoEvents();</code> but... it does not exist <em>a priori</em> in .NET 4.</p> <p>What to do?</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload