Exemple #1
0
 /// <summary>
 /// Gets a boolean indicating whether or not the specified <see cref="IUIElement"/> is a focus scope element
 /// </summary>
 /// <param name="element">The <see cref="IUIElement"/> to check</param>
 /// <returns>A boolean indicating whether or not the specified <see cref="IUIElement"/> is a focus scope element</returns>
 public static bool GetIsFocusScope(IUIElement element)
 {
     if (!element.DependencyProperties.ContainsKey(FocusManager.IsFocusScopeProperty))
     {
         return false;
     }
     return element.GetValue<bool>(FocusManager.IsFocusScopeProperty);
 }
Exemple #2
0
 /// <summary>
 /// Gets the focused <see cref="UIElement"/>, if any, within the specified focus scope
 /// </summary>
 /// <param name="focusScope">The <see cref="IUIElement"/> that represents the scope within which to find the focused element</param>
 /// <returns>A <see cref="UIElement"/> representing the focused element of the specified focus scope</returns>
 public static UIElement GetFocusedElement(IUIElement focusScope)
 {
     if (!focusScope.DependencyProperties.ContainsKey(FocusManager.FocusedElementProperty))
     {
         return null;
     }
     return focusScope.GetValue<UIElement>(FocusManager.FocusedElementProperty);
 }
Exemple #3
0
 /// <summary>
 /// Sets the focused <see cref="UIElement"/> within the specified focus scope
 /// </summary>
 /// <param name="focusScope">The <see cref="IUIElement"/> that represents the scope for which to set the focused element</param>
 /// <param name="focusedElement">The <see cref="UIElement"/> to set the focus to</param>
 public static void SetFocusedElement(IUIElement focusScope, UIElement focusedElement)
 {
     UIElement toUnfocus;
     if (!focusScope.DependencyProperties.ContainsKey(FocusManager.FocusedElementProperty))
     {
        FocusManager.AppendFocusProperties(focusScope);
     }
     toUnfocus = focusScope.GetValue<UIElement>(FocusManager.FocusedElementProperty);
     if(toUnfocus != null)
     {
         toUnfocus.Unfocus();
     }
     focusScope.SetValue(FocusManager.FocusedElementProperty, focusedElement);
     focusedElement.Focus();
 }
Exemple #4
0
 /// <summary>
 /// Gets a list of all the focusable <see cref="UIElement"/> contained within the specified focus scope
 /// </summary>
 /// <param name="focusScope">The focus scope <see cref="IUIElement"/></param>
 /// <returns>A list of all the focusable <see cref="UIElement"/> contained within the specified focus scope</returns>
 public static HashSet<UIElement> GetFocusableElements(IUIElement focusScope)
 {
     if (!focusScope.DependencyProperties.ContainsKey(FocusManager.FocusableElementsProperty))
     {
         return null;
     }
     return focusScope.GetValue<HashSet<UIElement>>(FocusManager.FocusableElementsProperty);
 }