-
Notifications
You must be signed in to change notification settings - Fork 2
HOW TO: Behaviors
Empty Keys edited this page May 8, 2018
·
1 revision
Starting version 1.12 library supports Behaviors. Implementation is based on http://github.com/Microsoft/XamlBehaviors . UI supports EventTriggerBehavior with CallMethodAction, ChangePropertyAction and InvokeCommandAction. Behaviors have it's own namespace in designer - EmptyKeys.UserInterface.Designer.Interactions.
You can use Binding on behaviors or actions, resources only on behaviors.
If you want your own custom behavior use Behavior or Behavior base classes - http://emptykeys.com/EmptyKeysUI/ht...tivity.htm
You have to make your own designer for UI Generator. See http://github.com/EmptyKeys/UI_Gene...teractions on how to do it. UI Generator can generate only dependency properties on Behaviors so keep that in mind.
Simple example:
<ek:UIRoot xmlns="http://schemas.microsoft.com/winfx/...tion" xmlns:x="http://schemas.microsoft.com/winfx/...xaml"
xmlns:mc="http://schemas.openxmlformats.org/m...2006" xmlns:d="http://schemas.microsoft.com/expres...2008"
xmlns:ek="clr-namespace:EmptyKeys.UserInterface.Designer;assembly=EmptyKeys.UserInterface.Designer"
xmlns:eki="clr-namespace:EmptyKeys.UserInterface.Designer.Interactions;assembly=EmptyKeys.UserInterface.Designer"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="400">
<Grid>
<Button Name="button1">
<eki:Interaction.Behaviors>
<eki:EventTriggerBehavior EventName="Click" SourceObject="{Binding Test}">
<eki:EventTriggerBehavior.Actions>
<eki:CallMethodAction MethodName="TestMethodName" TargetObject="{Binding Target}" />
<eki:ChangePropertyAction PropertyName="TestPropertyname1" TargetObject="{Binding Target}" Value="1" />
<eki:InvokeCommandAction Command="{Binding TestCommand}" CommandParameter="TestParam" />
</eki:EventTriggerBehavior.Actions>
</eki:EventTriggerBehavior>
</eki:Interaction.Behaviors>
</Button>
</Grid>
</ek:UIRoot>