public void SetLeftIndentLengthSettings()
        {
            var indentLength = TreeViewItemExtension.GetItemIndentLength(AttachedFrameworkElement);

            var count = AttachedFrameworkElement.FindAscendantCount <TreeViewItem, TreeView>();
            var leftIndentLengthDelta = count > 0 ? indentLength * count : 0;

            _templateSettings.SetValue(TreeViewItemTemplateSettings.ItemIndentThicknessDeltaProperty, new Thickness(leftIndentLengthDelta, 0, 0, 0));
        }
        private void HidePassword()
        {
            var start  = _revealTextBox.SelectionStart;
            var length = _revealTextBox.SelectionLength;

            _revealTextBox.Visibility = Visibility.Collapsed;
            AttachedFrameworkElement.Focus();

            AttachedFrameworkElement.GetType().GetMethod("Select", BindingFlags.Instance | BindingFlags.NonPublic)
            .Invoke(AttachedFrameworkElement, new object[] { start, length });
        }
Beispiel #3
0
        public override void OnApplyRequestedTheme(ElementTheme requestedTheme)
        {
            var elementType = AttachedFrameworkElement.GetType();
            var style       = RequestedThemeFactory.Current.Create(elementType, requestedTheme);

            AttachedFrameworkElement.SetValue(FrameworkElement.StyleProperty, style);
            AttachedFrameworkElement.UpdateLayout();
            AttachedFrameworkElement.UpdateDefaultStyle();

            OnApplyTemplate();
            ChangeVisualState(true);
        }
        private TextControlSelection GetSelection()
        {
            var selection =
                AttachedFrameworkElement.GetValue <TextSelection>("Selection",
                                                                  BindingFlags.NonPublic | BindingFlags.Instance);
            var textRangeType = selection.GetType().GetInterfaces().FirstOrDefault(x => x.Name == "ITextRange");

            var startTextPointer  = textRangeType.GetValue <object>(selection, "Start");
            var endEndTextPointer = textRangeType.GetValue <object>(selection, "End");

            var start = startTextPointer.GetValue <int>("Offset", BindingFlags.Instance | BindingFlags.NonPublic);
            var end   = endEndTextPointer.GetValue <int>("Offset", BindingFlags.Instance | BindingFlags.NonPublic);

            return(new TextControlSelection
            {
                Start = start,
                End = end
            });
        }
 protected override void RegisterEvents()
 {
     AttachedFrameworkElement.SetCurrentValue(UIElement.FocusableProperty, false);
     AddPropertyChangedHandler(TreeViewItem.IsSelectedProperty, OnPropertyChanged);
 }