Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>for your requirement, specially in WPF, you shouldn't be using timer or background worker to keep the view responsive. Instead you should be designing your app with MVVM pattern. MVVM is Model, View and View Model, where if there is a change in the model, the model updates the View Model, and the view model updates the view. This is done by just inheriting a "INotifyPropertyChanged" Interface. </p> <p>Here is a simple example</p> <p>Xaml part:</p> <pre><code>&lt;Window x:Class="SimpleMVVM.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="259" Width="445"&gt; &lt;Grid Margin="0,0,2,-3"&gt; &lt;Button x:Name="button" Content="Button" HorizontalAlignment="Left" Margin="10,33,0,0" VerticalAlignment="Top" Width="75"/&gt; &lt;Label x:Name="label" Content="{Binding Name}" HorizontalAlignment="Left" Margin="103,23,0,0" VerticalAlignment="Top" Width="220" BorderBrush="Black" BorderThickness="1" Height="32" Padding="0"/&gt; &lt;/Grid&gt; &lt;/Window&gt; </code></pre> <p>And The .cs Part</p> <pre><code>using System.ComponentModel; using System.Windows; namespace SimpleMVVM { /// &lt;summary&gt; /// Interaction logic for MainWindow.xaml /// &lt;/summary&gt; public partial class MainWindow : Window { private AnimalViewModel _animal= new AnimalViewModel (); public MainWindow() { InitializeComponent(); DataContext = _animal; button.Click += (sender, e) =&gt; _animal.Name = "Taylor" ; } } public class AnimalViewModel : AnimalModel { public AnimalViewModel () { } } public class AnimalModel : INotifyPropertyChanged { private string _name; public event PropertyChangedEventHandler PropertyChanged; public string Name { get { return _name; } set { if (_name != value) { _name = value; OnPropertyChanged("Name"); } } } private void OnPropertyChanged(string propertyName) { if (PropertyChanged != null) { PropertyChangedEventArgs args = new PropertyChangedEventArgs(propertyName); PropertyChanged(this, args); } } } } </code></pre> <p>No imagine that the button click is the update triggered by scheduler, you model get updated first that trigger a property changed event to update the view.</p> <p>Using this pattern your code will be much reliable.</p> <p>I hope this helps.</p> <p>Regards Jegan</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.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      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