Cookie Consent by Free Privacy Policy Generator
Privacy
Polipone
<novembre 2024>
lunmarmergiovensabdom
28293031123
45678910
11121314151617
18192021222324
2526272829301
2345678
Immagini

UniversalApp - UserControl

****************************************************************************

********* USER CONTROL: PROPRIETA E EVENTO SU PROPIETà PUBBLICA DELLO UC ***

****************************************************************************

0. Definire una proprietà pubblica per uno user control:

        [EditorBrowsable(EditorBrowsableState.Always)]

        private int _numSticker = 0;

        public int numSticker

        {

            get

            {

                return _numSticker;

            }

            set

            {

                _numSticker = value;

                imgSticker.Source = CSticker.getImageSticker(_numSticker);

            }

        }

 

 

PROPRIETA' UTILIZZABILE ANCHE TRAMITE UI tramite DependencyProperty

        [EditorBrowsable(EditorBrowsableState.Always)]

        public string TITLE

        {

            get { return (string)GetValue(TitleProperty); }

            set { SetValue(TitleProperty, value); }

        }

 

        public static readonly DependencyProperty TitleProperty =

            DependencyProperty.Register("TITLE", typeof(string), typeof(MYUSERCONTROL),

            new PropertyMetadata(0, OnTITLEPropertyChanged));

 

        private static void OnTITLEPropertyChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)

        {

            string myValue = e.NewValue.ToString();

            (d as MYUSERCONTROL).tbTitle.Text = myValue;

        }

 

 

 

 

1. Inserire i due eventi in testa allo user control

        public delegate void ValueChangedEventHandler(object sender, EventArgs e);

        public event ValueChangedEventHandler ValueChanged;

 

2. In un qualsiasi punto del codice dello UC, se vogliamo far scattare l'evento, aggiungiamo il codice

            if (ValueChanged != null)

            {

                ValueChanged(this, EventArgs.Empty);

            }

 

*********************************************************************************

Navigare verso un'altra finestra da uno user control

*********************************************************************************

 

((Frame)Window.Current.Content).Navigate(typeof(myPage));

 

Notifiche