jeudi 22 septembre 2016

Loading System.Windows.Interactivity.dll with reflection

I like to try loading System.Windows.Interactivity.dll with reflection so I can set it's location outside my project with a relative path where I want it.

Now in order to get this to work.

There are two XAML files that would usually use the dll for:

Interaction.Triggers
EventTrigger
Interaction.Behaviors

There are a few behavior classes such

public class SetLayerConditionsBtnBehavior : TriggerAction<Button>

that use GetValue and SetValue

public DataGrid DataGridObject
{
    get { return (DataGrid)GetValue(DataGridObjectProperty); }
    set { SetValue(DataGridObjectProperty, value); }
}

So with my limited knowledge on this I need to wrap these items in a class of my own, is that correct? I haven't wrapped anything before so would love some advice on how to proceed.

If I start by doing the following:

namespace SegmentJoin.Helpers
{
    public static class Interactivity
    {
        public static Type Interaction;
        public static Type TriggerAction;

        public static void LoadInteractivity()
        {
            Assembly assembly = Assembly.LoadFrom(@"..\Libraries\System.Windows.Interactivity.dll");
            //Set the type Interaction
            Interaction = assembly.GetType("System.Windows.Interactivity.Interaction");
            //Set the type TriggerAction
            TriggerAction = assembly.GetType("System.Windows.Interactivity.TriggerAction");
            //not sure on Interaction.Behaviors or the rest
        }
    }
}





Aucun commentaire:

Enregistrer un commentaire