protected virtual FrameworkElement CreateCommandLinkControl(PropertyDefinition d, int index)
        {
            var commandAtt =
                d.Descriptor.Attributes.OfType <Attribute>().FirstOrDefault(att => att is IPrefabCommand) as IPrefabCommand;

            var cl = new CommandLinkBlock
            {
                PrefabInvocation    = commandAtt,
                HorizontalAlignment = d.HorizontalAlignment,
                VerticalAlignment   = VerticalAlignment.Center,
                Padding             = new Thickness(4, 0, 4, 0),
                TextDecorations     = TextDecorations.Underline,
            };

            if (d.Descriptor.Attributes.OfType <AssignCommandDataAttribute>().Any())
            {
                cl.CommandDataAssignment = true;
            }


            cl.SetBinding(TextBlock.TextProperty, new Binding(d.Descriptor.Name));
            cl.SetBinding(CommandLinkBlock.CommandProperty, d.CreateOneWayBinding(index));

            if (cl.CommandDataAssignment)
            {
                cl.SetBinding(CommandLinkBlock.CommandDataProperty, new Binding("SelectedItems")
                {
                    RelativeSource =
                        new RelativeSource(
                            RelativeSourceMode.FindAncestor,
                            typeof(ItemsGrid), 1),
                    Mode = BindingMode.OneWay
                });
            }

            return(cl);
        }
Пример #2
0
        /// <summary>
        /// Creates the text block control.
        /// </summary>
        /// <param name="property">The property.</param>
        /// <returns></returns>
        protected virtual FrameworkElement CreateTextBlockControl(PropertyDefinition property)
        {
            var tb = new TextBlock
                {
                    HorizontalAlignment = property.HorizontalAlignment,
                    VerticalAlignment = VerticalAlignment.Center,
                    Padding = new Thickness(4, 0, 4, 0)
                };

            tb.SetBinding(TextBlock.TextProperty, property.CreateOneWayBinding());
            return tb;
        }