- realesmedia
- Posts: 85
- Joined:
Behavior with Event inside Style
Hi
I implemented Behavior in which there is an Event. If I attach this Behavior to the element that is inside Style.ControlTemplate ..., then the event is not called. When invoking Event, the list of delegates is empty. As I understand it, when using inside Styles, you need to clone the Behavior created in Style.
How to act in this case?
In the method of
I create a Behavior instance with an existing event. It works.
I implemented Behavior in which there is an Event. If I attach this Behavior to the element that is inside Style.ControlTemplate ..., then the event is not called. When invoking Event, the list of delegates is empty. As I understand it, when using inside Styles, you need to clone the Behavior created in Style.
How to act in this case?
In the method of
Code: Select all
Noesis::Ptr<Noesis::Freezable> LayoutDragElementBehavior::CreateInstanceCore() const
{
return *new LayoutDragElementBehavior(mDragEvent);
}
Code: Select all
<TabControl x:Name="tab" Visibility="Collapsed" TabStripPlacement="Bottom" BorderThickness="0.5" BorderBrush="#303030" SelectionChanged="OnTabSelectionChanged">
<TabControl.Resources>
<Style TargetType="{x:Type TabItem}">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type TabItem}">
<Grid Height="25">
<i:Interaction.Behaviors>
<docking:LayoutDragElementBehavior OnDrag="OnTabItemDrag"/>
</i:Interaction.Behaviors>
<Border Name="Border" Background="Transparent" BorderThickness="0" CornerRadius="0" Margin="0" BorderBrush="#303030">
<TextBlock />
</Border>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
</TabControl.Resources>
</TabControl>
-
sfernandez
Site Admin
- Posts: 3154
- Joined:
Re: Behavior with Event inside Style
Hi,
The Freezable class exposes the virtual method CloneCommonCore() where any inheriting class can perform their own clone code.
For example, the TriggerBase class in the Interactivity package (available in the Native SDK under Src/Packages/App/Interactivity/Src folder) uses that method to clone its collection of actions:
I think it is better to use the default constructor in the CreateInstanceCore method, and override the CloneCommonCore for extending the clone process.
The Freezable class exposes the virtual method CloneCommonCore() where any inheriting class can perform their own clone code.
For example, the TriggerBase class in the Interactivity package (available in the Native SDK under Src/Packages/App/Interactivity/Src folder) uses that method to clone its collection of actions:
Code: Select all
void NoesisApp::TriggerBase::CloneCommonCore(const Freezable* source)
{
ParentClass::CloneCommonCore(source);
TriggerActionCollection* thisActions = GetActions();
TriggerBase* trigger = (TriggerBase*)source;
TriggerActionCollection* actions = trigger->GetActions();
int numActions = actions->Count();
for (int i = 0; i < numActions; ++i)
{
Ptr<TriggerAction> action = actions->Get(i)->Clone();
thisActions->Add(action);
}
}
Re: Behavior with Event inside Style
Marking as solved. Thanks for your feedback.
Who is online
Users browsing this forum: Bing [Bot] and 2 guests