icsharpcode / WpfDesigner

The WPF Designer from SharpDevelop
MIT License
949 stars 251 forks source link

Adding binding option for events #23

Closed javidang closed 7 years ago

javidang commented 8 years ago

What I am intend to do: if I open context menu on events section of property grid, there will be set binding option, which will do following if clicked - will add attached property to element. For example. If I try to add binding to Loaded event of Grid, following will be added to Text

   <i:EventTrigger EventName="Loaded">
      <cmd:EventToCommand Command="{Binding Mode=OneWay, Path=LoadedCommand}"
                          PassEventArgsToCommand="True" />
    </i:EventTrigger>
  </i:Interaction.Triggers>

and these to declaration of window.

    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:cmd="clr-namespace:GalaSoft.MvvmLight.Command;assembly=GalaSoft.MvvmLight.Platform"

I am actually on it, but haven't completed "research" of code, and understand if it possible to insert corresponding text as child to parent element.

javidang commented 8 years ago

I found very very hacky way. But because it is attached property, compiler does not recognize <Interaction.Triggers> and makes adjusted control to disappear

jogibear9988 commented 8 years ago

Do you talk about SharpDevelop or WPFDesigner? When I look in the Example, there is no ContextMenu on the Events Section!

javidang commented 8 years ago

I am talking about WPFDesigner. I mean, after switching to events section, there is Textbox to put event name, and "right click" on it will bring text editor context menu (copy/pate/delete). I meant that one. But I adjusted it so when any text inputted, in code behind it adds the corresponding code for event binding.

javidang commented 8 years ago

I don't understand one thing, even I add corresponding libraries, to parserSettings it does not recognize it during parsing.

jogibear9988 commented 8 years ago

So the Problem is in your Code, not the WpfDesigner?

I don't understand one thing, even I add corresponding libraries, to parserSettings it does not recognize it during parsing.

What does the Parser not recognize?

javidang commented 8 years ago

Sure problem is not in WpfDesigner. As it "new" thing to parse attached properties such Interactivity.Triggers this method

static XamlPropertyInfo FindAttachedProperty(Type elementType, string propertyName)
        {
            XamlPropertyInfo pi = TryFindAttachedProperty(elementType, propertyName);
            if (pi == null) {
                pi = TryFindAttachedEvent(elementType, propertyName);
            }
            if (pi != null) {
                return pi;
            } else {
                throw new XamlLoadException("attached property " + elementType.Name + "." + propertyName + " not found");
            }
        }

cannot find it. I am not blaming anyone I just saying what I have encountered.

jogibear9988 commented 8 years ago

If you use the current Version (not the Nuget) then the parsing should work

jogibear9988 commented 8 years ago

If started today to work on support for Triggers and Behaviors (via a Addon Assembly), but I've no Schedule when it will be ready (because I'm going on Holiday on Friday)

javidang commented 8 years ago

If you use the current Version (not the Nuget) then the parsing should work

I am using this version.

If started today to work on support for Triggers and Behaviors (via a Addon Assembly), but I've no Schedule when it will be ready (because I'm going on Holiday on Friday)

I will try to make it work. But probably it will take long as I am not experienced on this project. By the way, happy vacations.

robsonfelix commented 4 years ago

hey @jogibear9988 , have you made any progress on the Triggers & Behaviors front?

jogibear9988 commented 4 years ago

there is a extension dll wich supports it