Ejemplo n.º 1
0
        private static NestedBindingsTree GetNestedBindingsTree(NestedBinding nestedBinding, MultiBinding multiBinding)
        {
            var tree = new NestedBindingsTree
            {
                Converter          = nestedBinding.Converter,
                ConverterParameter = nestedBinding.ConverterParameter,
                ConverterCulture   = nestedBinding.ConverterCulture
            };

            foreach (var bindingBase in nestedBinding.Bindings)
            {
                var binding            = bindingBase as Binding;
                var childNestedBinding = binding?.Source as NestedBinding;
                if (childNestedBinding != null && binding.Converter == null)
                {
                    tree.Nodes.Add(GetNestedBindingsTree(childNestedBinding, multiBinding));
                    continue;
                }

                tree.Nodes.Add(new NestedBindingNode(multiBinding.Bindings.Count));
                multiBinding.Bindings.Add(bindingBase);
            }

            return(tree);
        }
        private object GetTreeValue(NestedBindingsTree tree, object[] values, Type targetType, CultureInfo culture)
        {
            var objects = tree.Nodes.Select(x => x is NestedBindingsTree ? GetTreeValue((NestedBindingsTree)x, values, targetType, culture) : values[x.Index]).ToArray();
            var value   = tree.Converter.Convert(objects, targetType, tree.ConverterParameter, tree.ConverterCulture ?? culture);

            return(value);
        }
Ejemplo n.º 3
0
        private static NestedBindingsTree GetNestedBindingsTree(NestedBinding nestedBinding, MultiBinding multiBinding)
        {
            var tree = new NestedBindingsTree
            {
                Converter = nestedBinding.Converter,
                ConverterParameter = nestedBinding.ConverterParameter,
                ConverterCulture = nestedBinding.ConverterCulture
            };
            foreach (var bindingBase in nestedBinding.Bindings)
            {
                var binding = bindingBase as Binding;
                var childNestedBinding = binding?.Source as NestedBinding;
                if (childNestedBinding != null && binding.Converter == null)
                {
                    tree.Nodes.Add(GetNestedBindingsTree(childNestedBinding, multiBinding));
                    continue;
                }

                tree.Nodes.Add(new NestedBindingNode(multiBinding.Bindings.Count));
                multiBinding.Bindings.Add(bindingBase);
            }

            return tree;
        }
 public NestedBindingConverter(NestedBindingsTree tree)
 {
     Tree = tree;
 }
 public NestedBindingConverter(NestedBindingsTree tree)
 {
     Tree = tree;
 }
 private object GetTreeValue(NestedBindingsTree tree, object[] values, Type targetType, CultureInfo culture)
 {
     var objects = tree.Nodes.Select(x => x is NestedBindingsTree ? GetTreeValue((NestedBindingsTree)x, values, targetType, culture) : values[x.Index]).ToArray();
     var value = tree.Converter.Convert(objects, targetType, tree.ConverterParameter, tree.ConverterCulture ?? culture);
     return value;
 }