using System; using System.Collections.Generic; using System.Text; using System.Windows; using System.Windows.Controls; using System.Windows.Data; using System.Windows.Documents; using System.Windows.Input; using System.Windows.Media; using System.Windows.Media.Imaging; using System.Windows.Navigation; using System.Windows.Shapes; namespace CustomWPF { /// /// Interaction logic for Laskuri.xaml /// public partial class Laskuri : UserControl { public Laskuri() { InitializeComponent(); } public static readonly RoutedEvent ChangeEvent = EventManager.RegisterRoutedEvent( "Change", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(Laskuri)); // Provide CLR accessors for the event public event RoutedEventHandler Change { add { AddHandler(ChangeEvent, value); } remove { RemoveHandler(ChangeEvent, value); } } protected virtual void CountChanged() { RoutedEventArgs args = new RoutedEventArgs(); args.RoutedEvent = ChangeEvent; RaiseEvent(args); } public static readonly DependencyProperty CountPropert = DependencyProperty.Register("Count", typeof(int), typeof(Laskuri)); public int Count { get { return (int)GetValue(CountPropert); } set { SetValue(CountPropert, value); labelLaskuri.Content = Convert.ToString(value); //LISÄÄ TARKISTUS ETTEI CountChanged():iä suoriteta, // jos kukaan ei ole kiinnostunut niistä //if (??? != null) { //MessageBox.Show("CountChange executed"); CountChanged(); //lisää diff-parametri! } } } } }