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:
Hello Sreeni,
Thank you for your post(s).
Unfortunately, your most recent post ended up being mostly blank, white space. I have been investigating into the behavior you described in your initial post by creating a XamDataTree with nodes that have ItemTemplates and EditorTemplates, but so far, I haven't been able to reproduce this behavior you are describing. The stack trace you provided also is not really of much help, except that internally, the XamDataTree appears that it is making calls to its "exit edit mode" related methods, but I'm not seeing where it actually enters edit mode in this case. I'm also not entirely sure what the "controls:TextEditor" object is that you are placing in some of your EditorTemplates. Could you please elaborate on what this element is?
My tests were made using Infragistics for WPF 2015 Volume 1, specific version 15.1.20151.2122, and I have attached the sample project that I have used to test this. Please test this project on your machine, as whether or not it works correctly may help to indicate the nature of this issue. If the project does not work correctly, this indicates either a problem possibly specific to your environment or a difference in the DLL versions we are using. If it does work correctly, then this indicates a possible problem in the code of your application.
Or if this sample project is not an accurate demonstration of what you are looking to achieve, please feel free to modify it and send it back so it reproduces these issues you are seeing. Or, send a small sample project of your own if you have one you can share.
Pleas let me know if you have any other questions or concerns on this matter.
Sincerely,AndrewAssociate DeveloperInfragistics Inc.www.infragistics.com/support
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