The InteractionHelper provides controls with support for all of the common interactions like mouse movement, mouse clicks, key presses, etc., and also incorporates proper event semantics when the control is disabled.
Ejemplo n.º 1
0
        /// <summary>
        /// Initializes a new instance of the
        /// <see cref="T:WinRTXamlToolkit.Controls.TreeView" /> class.
        /// </summary>
        public TreeView()
        {
            var pcc = new PropertyChangeEventSource <Style>(this, "ItemContainerStyle");

            pcc.ValueChanged  += OnItemContainerStylePropertyChanged;
            DefaultStyleKey    = typeof(TreeView);
            ItemsControlHelper = new ItemsControlHelper(this);
            Interaction        = new InteractionHelper(this);
        }
Ejemplo n.º 2
0
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="T:WinRTXamlToolkit.Controls.TreeView" /> class.
 /// </summary>
 public TreeView()
 {
     var pcc = new PropertyChangeEventSource<Style>(this, "ItemContainerStyle");
     pcc.ValueChanged += OnItemContainerStylePropertyChanged;
     DefaultStyleKey = typeof(TreeView);
     ItemsControlHelper = new ItemsControlHelper(this);
     Interaction = new InteractionHelper(this);
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Handle keys related to scrolling.
        /// </summary>
        /// <param name="key">The key to handle.</param>
        /// <returns>A value indicating whether the key was handled.</returns>
        private bool HandleScrollKeys(VirtualKey key)
        {
            ScrollViewer scrollHost = ItemsControlHelper.ScrollHost;

            if (scrollHost != null)
            {
                // Some keys (e.g. Left/Right) need to be translated in RightToLeft mode
                VirtualKey invariantKey = InteractionHelper.GetLogicalKey(FlowDirection, key);

                switch (invariantKey)
                {
                case VirtualKey.PageUp:
                    // Move horizontally if we've run out of room vertically
                    if (!NumericExtensions.IsGreaterThan(scrollHost.ExtentHeight, scrollHost.ViewportHeight))
                    {
                        scrollHost.PageLeft();
                    }
                    else
                    {
                        scrollHost.PageUp();
                    }
                    return(true);

                case VirtualKey.PageDown:
                    // Move horizontally if we've run out of room vertically
                    if (!NumericExtensions.IsGreaterThan(scrollHost.ExtentHeight, scrollHost.ViewportHeight))
                    {
                        scrollHost.PageRight();
                    }
                    else
                    {
                        scrollHost.PageDown();
                    }
                    return(true);

                case VirtualKey.Home:
                    scrollHost.ScrollToTop();
                    return(true);

                case VirtualKey.End:
                    scrollHost.ScrollToBottom();
                    return(true);

                case VirtualKey.Left:
                    scrollHost.LineLeft();
                    return(true);

                case VirtualKey.Right:
                    scrollHost.LineRight();
                    return(true);

                case VirtualKey.Up:
                    scrollHost.LineUp();
                    return(true);

                case VirtualKey.Down:
                    scrollHost.LineDown();
                    return(true);
                }
            }
            return(false);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Initializes a new instance of the
 /// <see cref="T:WinRTXamlToolkit.Controls.TreeViewItem" /> class.
 /// </summary>
 public TreeViewItem()
 {
     DefaultStyleKey = typeof(TreeViewItem);
     Interaction = new InteractionHelper(this);
 }