Example #1
0
        // Token: 0x060058D8 RID: 22744 RVA: 0x001892D8 File Offset: 0x001874D8
        private void UpdateSelectedValue(object selectedItem)
        {
            BindingExpression bindingExpression = this.PrepareSelectedValuePathBindingExpression(selectedItem);

            if (bindingExpression != null)
            {
                bindingExpression.Activate(selectedItem);
                object value = bindingExpression.Value;
                bindingExpression.Deactivate();
                base.SetValue(TreeView.SelectedValuePropertyKey, value);
                return;
            }
            base.ClearValue(TreeView.SelectedValuePropertyKey);
        }
Example #2
0
        private void UpdateSelectedValue(object selectedItem)
        {
            BindingExpression expression = PrepareSelectedValuePathBindingExpression(selectedItem);

            if (expression != null)
            {
                expression.Activate(selectedItem);
                object selectedValue = expression.Value;
                expression.Deactivate();

                SetValue(SelectedValuePropertyKey, selectedValue);
            }
            else
            {
                ClearValue(SelectedValuePropertyKey);
            }
        }
        // Token: 0x060057FB RID: 22523 RVA: 0x00185FB0 File Offset: 0x001841B0
        private static string GetPrimaryText(object item, BindingExpression primaryTextBinding, DependencyObject primaryTextBindingHome)
        {
            DependencyObject dependencyObject = item as DependencyObject;

            if (dependencyObject != null)
            {
                string text = (string)dependencyObject.GetValue(TextSearch.TextProperty);
                if (!string.IsNullOrEmpty(text))
                {
                    return(text);
                }
            }
            if (primaryTextBinding != null && primaryTextBindingHome != null)
            {
                primaryTextBinding.Activate(item);
                object value = primaryTextBinding.Value;
                return(TextSearch.ConvertToPlainText(value));
            }
            return(TextSearch.ConvertToPlainText(item));
        }
        private static string GetPrimaryText(object item, BindingExpression primaryTextBinding, DependencyObject primaryTextBindingHome)
        {
            // Order of precedence for getting Primary Text is as follows:
            //
            // 1) PrimaryText
            // 2) PrimaryTextPath (TextSearch.TextPath or ItemsControl.DisplayMemberPath)
            // 3) GetPlainText()
            // 4) ToString()

            DependencyObject itemDO = item as DependencyObject;

            if (itemDO != null)
            {
                string primaryText = (string)itemDO.GetValue(TextProperty);

                if (!String.IsNullOrEmpty(primaryText))
                {
                    return(primaryText);
                }
            }

            // Here hopefully they've supplied a path into their object which we can use.
            if (primaryTextBinding != null && primaryTextBindingHome != null)
            {
                // Take the binding that we hooked up at the beginning of the search
                // and apply it to the current item.  Then, read the value of the
                // ItemPrimaryText property (where the binding actually lives).
                // Try to convert the resulting object to a string.
                primaryTextBinding.Activate(item);

                object primaryText = primaryTextBinding.Value;

                return(ConvertToPlainText(primaryText));
            }

            return(ConvertToPlainText(item));
        }