Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
790
Issues in enter editing mode with XamDataTReeNode
posted

Hi,

I am trying to enter edit mode after the node is created using a behavior. However it comes out of the edit mode automatically. Please help where I'm doing wrong. 

Code for xaml and behavior:

xaml:

<ig:XamDataTree
ItemsSource="{Binding Path=ProjectCollection}"
ActiveDataItem="{Binding ActiveNode, Mode=TwoWay}"
AutomationProperties.AutomationId="aid_ProjectExplorerTree">

<ig:XamDataTree.EditingSettings>
<ig:TreeEditingSettings AllowEditing="True" AllowDeletion="False" IsEnterKeyEditingEnabled="False" IsF2EditingEnabled="True" IsOnNodeActiveEditingEnabled="False" />
</ig:XamDataTree.EditingSettings>

<ig:XamDataTree.SelectionSettings>
<ig:TreeSelectionSettings NodeSelection="Single" />
</ig:XamDataTree.SelectionSettings>

<ig:XamDataTree.InputBindings>
<KeyBinding Key="Delete" Command="{Binding EditManager.DeleteCommand}" />
<KeyBinding Gesture="Ctrl+D" Command="{Binding EditManager.DuplicateCommand}"/>
<KeyBinding Key="F4" Command="{Binding EditManager.PropertiesCommand}"/>
</ig:XamDataTree.InputBindings>

<i:Interaction.Behaviors>
<behaviors:XamDataTreeCommonBehavior />
<workbench:TreeNodeEditBehavior />
</i:Interaction.Behaviors>

<i:Interaction.Triggers>
<i:EventTrigger EventName="MouseDoubleClick">
<i:InvokeCommandAction Command="{Binding EditManager.OpenCommand}">
<i:InvokeCommandAction.CommandParameter>
<MultiBinding Converter="{StaticResource CapabilityParameterConverter}">
<Binding Source="{StaticResource BindingProxy}" Path="Data.Project"/>
<Binding Source="{StaticResource BindingProxy}" Path="Data.ActiveNode"/>
</MultiBinding>
</i:InvokeCommandAction.CommandParameter>
</i:InvokeCommandAction>
</i:EventTrigger>
</i:Interaction.Triggers>

<ig:XamDataTree.GlobalNodeLayouts>

<ig:NodeLayout Key="Project" TargetTypeName="Project" DisplayMemberPath="Name" IsExpandedMemberPath="ViewData.IsVisuallyExpanded">
<ig:NodeLayout.ItemTemplate>
<DataTemplate DataType="{x:Type structures:Project}">
<StackPanel Orientation="Horizontal" ContextMenu="{StaticResource ResourceKey=ProjectExplorerContextMenu}">
<Image Height="16" Width="16" Margin="1 0" Source="/EAB.Premium.Client.Framework;component/Images/Project.png" />
<TextBlock Text="{Binding Data.Name}"/>
</StackPanel>
</DataTemplate>
</ig:NodeLayout.ItemTemplate>
</ig:NodeLayout>

<ig:NodeLayout Key="Proposals" TargetTypeName="Proposal" DisplayMemberPath="Name" HeaderText="Proposals" IsExpandedMemberPath="ViewData.IsProposalVisuallyExpanded">
<ig:NodeLayout.ItemTemplate>
<DataTemplate DataType="structures:Proposal">
<StackPanel Orientation="Horizontal" ContextMenu="{StaticResource ResourceKey=ProjectExplorerContextMenu}">
<Image Height="16" Width="16" Margin="1 0" Source="/EAB.Premium.Client.Framework;component/Images/RestOf.png" />
<TextBlock Text="{Binding Data.Name}" />
</StackPanel>
</DataTemplate>
</ig:NodeLayout.ItemTemplate>

<ig:NodeLayout.NodeLayouts>
<ig:NodeLayout Key="ProposalProposalParts" HeaderText="Proposal parts" TargetTypeName="ProposalProposalPart"
DisplayMemberPath="ProposalPart.Name" IsExpandedMemberPath="ViewData.IsVisuallyExpanded">
<ig:NodeLayout.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" ContextMenu="{StaticResource ProjectExplorerContextMenu}">
<Image Height="16" Width="16" Margin="1 0" Source="/EAB.Premium.Client.Framework;component/Images/Proposal.png" />
<TextBlock Text="{Binding Data.ProposalPart.Name}"/>
</StackPanel>
</DataTemplate>
</ig:NodeLayout.ItemTemplate>
<ig:NodeLayout.NodeLayouts>
<ig:NodeLayout Key="ViewData.ActiveCommercialScenarioCollection" TargetTypeName="CommercialScenario" DisplayMemberPath="Name">
<ig:NodeLayout.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" ContextMenu="{StaticResource ProjectExplorerContextMenu}">
<Image Height="16" Width="16" Margin="1 0" Source="/EAB.Premium.Client.Framework;component/Images/Active.png"/>
<TextBlock Text="{Binding Data.Name}"/>
</StackPanel>
</DataTemplate>
</ig:NodeLayout.ItemTemplate>
</ig:NodeLayout>
</ig:NodeLayout.NodeLayouts>
</ig:NodeLayout>
<ig:NodeLayout Key="CommercialScenarios" TargetTypeName="CommercialScenario" DisplayMemberPath="Name" HeaderText="Commercial scenarios">
<ig:NodeLayout.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" ContextMenu="{StaticResource ProjectExplorerContextMenu}">
<Image Height="16" Width="16" Margin="1 0" Source="/EAB.Premium.Client.Framework;component/Images/CommercialScenario.png"/>
<TextBlock Text="{Binding Data.Name}" />
</StackPanel>
</DataTemplate>
</ig:NodeLayout.ItemTemplate>
</ig:NodeLayout>
</ig:NodeLayout.NodeLayouts>
</ig:NodeLayout>

<ig:NodeLayout Key="OrderPlans" TargetTypeName="OrderPlan" DisplayMemberPath="Name" HeaderText="Order plans">
<ig:NodeLayout.ItemTemplate>
<DataTemplate DataType="structures:OrderPlan">
<StackPanel Orientation="Horizontal" ContextMenu="{StaticResource ResourceKey=ProjectExplorerContextMenu}">
<Image Height="16" Width="16" Margin="1 0" Source="/EAB.Premium.Client.Framework;component/Images/Order.png" />
<TextBlock Text="{Binding Data.Name}" />
</StackPanel>
</DataTemplate>
</ig:NodeLayout.ItemTemplate>
<ig:NodeLayout.EditorTemplate>
<DataTemplate>
<controls:TextEditor IsAlwaysInEditMode="False" Text="{Binding Path=Data.Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</DataTemplate>
</ig:NodeLayout.EditorTemplate>
</ig:NodeLayout>

<ig:NodeLayout Key="AssociatedRiskAnalyses" TargetTypeName="RiskAnalysis" DisplayMemberPath="Name" HeaderText="Risk analyses">
<ig:NodeLayout.ItemTemplate>
<DataTemplate DataType="structures:RiskAnalysis">
<StackPanel Orientation="Horizontal" ContextMenu="{StaticResource ResourceKey=ProjectExplorerContextMenu}">
<Image Height="16" Width="16" Margin="1 0" Source="/EAB.Premium.Client.Framework;component/Images/Order.png" />
<TextBlock Text="{Binding Data.Name}" />
</StackPanel>
</DataTemplate>
</ig:NodeLayout.ItemTemplate>
<ig:NodeLayout.EditorTemplate>
<DataTemplate>
<controls:TextEditor IsAlwaysInEditMode="False" Text="{Binding Path=Data.Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}"/>
</DataTemplate>
</ig:NodeLayout.EditorTemplate>
</ig:NodeLayout>

<ig:NodeLayout Key="ViewData.ProductList" TargetTypeName="String" HeaderText="Product list">
</ig:NodeLayout>


<ig:NodeLayout Key="ProposalParts" TargetTypeName="ProposalPart" DisplayMemberPath="Name" HeaderText="Proposal parts">
<ig:NodeLayout.ItemTemplate>
<DataTemplate DataType="structures:ProposalPart">
<StackPanel Orientation="Horizontal" ContextMenu="{StaticResource ResourceKey=ProjectExplorerContextMenu}">
<Image Height="16" Width="16" Margin="1 0" Source="/EAB.Premium.Client.Framework;component/Images/Proposal.png" />
<TextBlock Text="{Binding Data.Name}"/>
</StackPanel>
</DataTemplate>
</ig:NodeLayout.ItemTemplate>
<ig:NodeLayout.EditorTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<Image Height="16" Width="16" Margin="1 0" Source="/EAB.Premium.Client.Framework;component/Images/Proposal.png" />
<TextBox Text="{Binding Data.Name, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
</StackPanel>
</DataTemplate>
</ig:NodeLayout.EditorTemplate>

<ig:NodeLayout.NodeLayouts>
<ig:NodeLayout Key="CommercialScenarios" TargetTypeName="CommercialScenario" DisplayMemberPath="Name">

<ig:NodeLayout.ItemTemplate>
<DataTemplate DataType="structures:CommercialScenario">
<StackPanel Orientation="Horizontal" ContextMenu="{StaticResource ResourceKey=ProjectExplorerContextMenu}">
<Image x:Name="CommercialScenario" Height="16" Width="16" Margin="1 0" Source="/EAB.Premium.Client.Framework;component/Images/CommercialScenario.png"/>
<TextBlock Text="{Binding Data.Name}" />
</StackPanel>
</DataTemplate>
</ig:NodeLayout.ItemTemplate>
</ig:NodeLayout>
</ig:NodeLayout.NodeLayouts>
</ig:NodeLayout>
</ig:XamDataTree.GlobalNodeLayouts>
</ig:XamDataTree>

Behavior:

public class TreeNodeEditBehavior : Behavior
{
protected override void OnAttached()
{
base.OnAttached();
AssociatedObject.InitializeNode += AssociatedObjectOnInitializeNode;
}

protected override void OnDetaching()
{
AssociatedObject.InitializeNode -= AssociatedObjectOnInitializeNode;
base.OnDetaching();
}

private void AssociatedObjectOnInitializeNode(object sender, InitializeNodeEventArgs e)
{
var tree = sender as XamDataTree;
var node = e.Node.Data as NodeBase;
if (tree != null && node != null && node.IsEditable)
{
tree.EnterEditMode(e.Node);
}
}
}

Error from stacktrace:

Parents
No Data
Reply
  • 790
    Offline posted

    Xaml Code:

    <ig:XamDataTree
    ItemsSource="{Binding Path=ProjectCollection}"
    ActiveDataItem="{Binding ActiveNode, Mode=TwoWay}"
    AutomationProperties.AutomationId="aid_ProjectExplorerTree">









































    DisplayMemberPath="ProposalPart.Name" IsExpandedMemberPath="ViewData.IsVisuallyExpanded">

























































































    Attached stacktrace after enter edit mode and immediately exiting edit mode:

    if I cancel exit edit mode using e.cancel = true in behavior i see a check box node. This is very interesting.

    Please help at the earliest.

    Thanks,

    Sreeni

Children