Note that there are some explanatory texts on larger screens.

plurals
  1. POHow send a static object in to event for `PropertyChanged`
    primarykey
    data
    text
    <p>I have a project by MVVM pattern. also I have a User Control in it. This user Control has a static DependencyProperty</p> <pre><code>public partial class RadarView : INotifyPropertyChanged { public static DispatcherTimer Timer { get; set; } public static readonly DependencyProperty RequestTypeProperty = DependencyProperty.Register("RequestType", typeof(RadarRequestType), typeof(RadarView), new FrameworkPropertyMetadata(new RadarRequestType(), RequestTypeChanged)); public RadarRequestType RequestType { get { return (RadarRequestType)GetValue(RequestTypeProperty); } set { SetValue(RequestTypeProperty, value); } } public static void RequestTypeChanged(DependencyObject dobject, DependencyPropertyChangedEventArgs args) { var radar = (RadarView)dobject; if (Timer == null) Timer = new DispatcherTimer { Interval = new TimeSpan(0, 0, 1) }; Timer.Tick += DispatcherTimerTick; Timer.Start(); } private static void DispatcherTimerTick(object sender, EventArgs e) { StartText = DateTime.Now.Second.ToString(); PropertyChanged(this, new PropertyChangedEventArgs("StartText")); } public static event PropertyChangedEventHandler PropertyChanged = delegate { }; } </code></pre> <p>My problem is in DispatcherTimerTick , because this in it event is same my user Control and it is not static. Message of this build error is : Keyword 'this' is not valid in a static property, static method, or static field initializer</p> <p>In fact I need to send (RadarView)dobject to DispatcherTimerTick event. How can do I?</p>
    singulars
    1. This table or related slice is empty.
    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. 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