|
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using System.Timers;
namespace BindableConverterParameterTake2
{
class MainViewModel : INotifyPropertyChanged
{
public MainViewModel()
{
_FirstName = "ABC";
_LastName = "DEF";
Timer t = new Timer(2000);
bool state = false;
t.Elapsed += new ElapsedEventHandler((s, e) =>
{
if (state)
{
ConcatSign = "-";
}
else
{
ConcatSign = " ";
}
state = !state;
});
t.Start();
}
private string _FirstName;
public string FirstName
{
get { return _FirstName; }
set { SetProperty(ref _FirstName, value, "FirstName"); }
}
private string _LastName;
public string LastName
{
get { return _LastName; }
set { SetProperty(ref _LastName, value, "LastName"); }
}
private string _ConcatSign;
public string ConcatSign
{
get { return _ConcatSign; }
set { SetProperty(ref _ConcatSign, value, "ConcatSign"); }
}
private void SetProperty<T>(ref T field, T value, string propertyName)
{
if (!EqualityComparer<T>.Default.Equals(field, value))
{
field = value;
var handler = PropertyChanged;
if (handler != null)
{
handler(this, new PropertyChangedEventArgs(propertyName));
}
}
}
public event PropertyChangedEventHandler PropertyChanged;
}
}
|
By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.
If a file you wish to view isn't highlighted, and is a text file (not binary), please
let us know and we'll add colourisation support for it.
This member has not yet provided a Biography. Assume it's interesting and varied, and probably something to do with programming.