Interaction Triggers in Style in ResourceDictionary WPF

As far as I know, Interaction.Triggers can not be applied in Style, respectively and in a ResourceDictionary. But you can do so, to determine the ComboBox as a resource with x:Shared=”False” and reference it for ContentControl like this: <Window.Resources> <ComboBox x:Key=”MyComboBox” x:Shared=”False” ItemsSource=”{Binding Branches}” DisplayMemberPath=”BranchName” SelectedItem=”{Binding SelectedBranch}”> <i:Interaction.Triggers> <i:EventTrigger EventName=”SelectionChanged”> <i:InvokeCommandAction Command=”{Binding SelectCustomerCommand}” /> </i:EventTrigger> … Read more

Access ResourceDictionary items programmatically

Got it solved. I needed to: load my resource dictionary merge it with the application’s resources load my control template from the application resource As part of loading the resource dictionary, i also had to register the pack URI scheme. I then had to deal with some crazy COM based exceptions due to slight errors … Read more

WPF Events in ResourceDictionary for a ControlTemplate

A ResourceDictionary can have code behind just like Windows etc. so you could add an event handler and call DragMove from there Setting up the code behind requires a couple of steps. If your ResourceDictionary is called MetroStyleResourceDictionary.xaml you add a new file in Visual Studio in the same folder called MetroStyleResourceDictionary.xaml.cs The code behind … Read more

Binding as a Resource

Direct answer to your question is “yes, you can define a binding as a resource”. The problem here is how do you then make any use of it? One possibility is to create an extension class which would pull the binding from the resources and apply it: public class BindingResourceExtension : StaticResourceExtension { public BindingResourceExtension() … Read more