Exemple #1
0
        //--------------------------------------------------------------
        #region Creation & Cleanup
        //--------------------------------------------------------------

        /// <summary>
        /// Initializes a new instance of the <see cref="TabItem"/> class.
        /// </summary>
        public TabItem()
        {
            Style = "TabItem";

            // The user might change the IsSelected property directly. For this case we catch the
            // Changed event of the IsSelected property.
            var isSelected = Properties.Get <bool>(IsSelectedPropertyId);

            isSelected.Changed += (s, e) =>
            {
                // The user has set IsSelected directly:
                if (IsSelected && TabControl != null)
                {
                    TabControl.Select(this);
                }
            };
        }
Exemple #2
0
        //--------------------------------------------------------------
        #region Methods
        //--------------------------------------------------------------

        /// <inheritdoc/>
        protected override void OnHandleInput(InputContext context)
        {
            base.OnHandleInput(context);

            if (!IsLoaded)
            {
                return;
            }

            var inputService = InputService;

            // When clicked, call TabControl.Select().
            if (IsMouseOver &&
                !inputService.IsMouseOrTouchHandled &&
                inputService.IsPressed(MouseButtons.Left, false))
            {
                inputService.IsMouseOrTouchHandled = true;
                if (TabControl != null)
                {
                    TabControl.Select(this);
                }
            }
        }