This is .xaml File
<ig:XamNetworkNode x:Name="xnn" Background="AliceBlue" NodeControlAttachedEvent="Xnn_NodeControlAttachedEvent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemsSource="{Binding Persons}" ZoomLevel="2" LineEndCap="SolidArrow" LineCapSize="10" SelectionType="Single" Grid.Row="3" FontSize="20" SelectedNodesCollectionChanged="xnn_SelectedNodesCollectionChanged" > <ig:XamNetworkNode.GlobalNodeLayouts> <ig:NetworkNodeNodeLayout x:Name="xmnode" TargetTypeName="Person" NodeStyle="{StaticResource MyNodeStyle}" ConnectionsMemberPath="Connections" ConnectionTargetMemberPath="Target" ConnectionWeightMemberPath="Weight" ToolTipMemberPath="ToolTip" DisplayMemberPath="Name" /> </ig:XamNetworkNode.GlobalNodeLayouts>
</ig:XamNetworkNode>
Iin xaml.cs
private void xnn_SelectedNodesCollectionChanged(object sender, Infragistics.Controls.Maps.NetworkNodeSelectionEventArgs e) { for (int i = 0; i < xnn.SelectedNodes.Count; i++) { this.tb_DisaplayNode.Text = ((Person)xnn.SelectedNodes[i].Data).Name; } }
This event is not raising while I am selecting any node but It is raising in some other event,
So not able to find the current selected node
Hello Rajni,
I followed the steps you suggested and was unable to reproduce the behavior you're describing. I created a sample XamNetworkNode and enabled selection and handled the selection changed event. The event fired every time I selected a different node.
I have attached the sample project I used to test this. Please test this project on your PC; whether or not it works correctly may help indicate the nature of this problem.
If the project does not work correctly, then the change in behavior is due to differences in your environment from mine and these differences can be anything from operating system version to the specific version of the Infragistics DLL versions used. My test was performed using version 18.2.20182.186 in Infragistics for WPF 2018 Volume 2. Please provide more details about your machine and version of the assemblies that you are referencing so that I can modify the environment that I am testing in to match yours.
If the project does show the product feature working correctly, then more information will be needed to reproduce the issue in a sample that can be used for debugging. It will help if you can provide a small, isolated sample application that demonstrates the behavior you are seeing. This can be done by either be done by making the sample that I provided more like your application or by isolating the behavior from your application by removing dependencies on any third parties or databases.
Please let me know if I can provide any further assistance.
XamNetworkNode.zip
Thankyou so much Mike.I got the exact problem now.Why this event is not working fine.This is happening due to style.When I removed style , it started working but I am not getting why this happened
Due to security issues , I can't share my complete code.Is there any other way to figure our this style related problem or can you share your sample code that how I can apply styles in my project
<UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:ig="http://schemas.infragistics.com/xaml" xmlns:ignore="http://www.galasoft.ch/ignore" xmlns:Properties="clr-namespace:PersonGraph.Properties" x:Class="PersonGraph.MainWindow" xmlns:vm="clr-namespace:PersonGraph.ViewModel" mc:Ignorable="d ignore" Height="700" Width="600" > <!--<UserControl.DataContext> <viewModel:ViewModelLocator/> </UserControl.DataContext>--> <!--<Style x:Key="MyNodeStyle" TargetType="{x:Type ig:NetworkNodeNodeControl}">--> <!--<UserControl.DataContext> <Binding Path="Main" Source="."/> </UserControl.DataContext>--> <UserControl.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Skins/MainSkin.xaml" /> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </UserControl.Resources> <Grid VerticalAlignment="Stretch"> <Grid.RowDefinitions> <RowDefinition/> <RowDefinition Height="auto"/> </Grid.RowDefinitions> <TabControl Grid.Row="0" VerticalAlignment="Stretch"> <TabItem Header="Main"> <Grid x:Name="LayoutRoot"> <Grid.Resources> <!-- https://www.infragistics.com/help/wpf/infragisticswpf.controls.maps.xamnetworknode~infragistics.controls.maps.networknodenodecontrol_members --> <!-- Configuration: *CFG* - text color, font shadow color text color: Foreground="White" font shadow color: <DropShadowEffect Color="Black" --> <Style x:Key="MyNodeStyle" TargetType="{x:Type ig:NetworkNodeNodeControl}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ig:NetworkNodeNodeControl}"> <Grid x:Name="ButtonGrid"> <Border CornerRadius="20" Background="{Binding Color}" BorderThickness="0"> <TextBox Background="Transparent" IsReadOnly="True" Text="{Binding Name}" Padding="20" BorderThickness="0" FontSize="{Binding FontSize}" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Center"> <TextBox.Resources> <Style TargetType="{x:Type TextBox}"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Foreground" Value="Blue"/> </Trigger> <Trigger Property="IsMouseOver" Value="False"> <Setter Property="Foreground" Value="White"/> </Trigger> </Style.Triggers> </Style> </TextBox.Resources> <TextBox.Effect> <DropShadowEffect ShadowDepth="3" Color="Black" Opacity="1" BlurRadius="3" /> </TextBox.Effect> </TextBox> </Border> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style> </Grid.Resources> <Grid.RowDefinitions> <RowDefinition Height="auto"/> <RowDefinition Height="auto"/> <RowDefinition Height="auto"/> <RowDefinition/> </Grid.RowDefinitions> <Menu Grid.Row="0"> <MenuItem Header="Exit" Command="{Binding CmdExitApplication}"/> <MenuItem Header="Fetch Data" Command="{Binding CmdFetch}"/> <MenuItem Header="Load Test Data" Command="{Binding CmdFetchTest}"/> <TextBox Text="Sample # 781239, 998495"/> </Menu> <TextBlock Grid.Row="1" FontSize="24" FontWeight="Bold" Foreground="Purple" Background="Transparent" Text="{Binding WelcomeTitle}" VerticalAlignment="Top" Height="auto" HorizontalAlignment="Stretch" TextWrapping="Wrap" /> <StackPanel Grid.Row="2" Orientation="Horizontal"> <!-- <TextBox Text="{Binding OrigAcctID, Delay=1000, UpdateSourceTrigger=PropertyChanged}"/> --> <Button x:Name="btnFetchData" Content="Fetch Data" Margin="5" Padding="5" Command="{Binding CmdFetch}" Visibility="Hidden"/> <!--<Label Content="ID" VerticalAlignment="Center"/>--> <TextBox x:Name="txtOrigAcct" Text="{Binding OrigAcctID}" Padding="5" Width="150" VerticalAlignment="Center" Visibility="Hidden" /> <Label Content="PPLStatus" VerticalAlignment="Center"/> <TextBox x:Name="txtPPLStatus" Text="{Binding PPLStatus}" Padding="5" Width="50" VerticalAlignment="Center" LostFocus="OrigAcctTxt_LostFocus" /> <!--<Label Content="Depth" VerticalAlignment="Center"/>--> <Label Content="Depth" VerticalAlignment="Center"/> <ComboBox x:Name = "cmbDepth" Margin="5" Padding="5" Width="50" ItemsSource = "{Binding depth}" SelectedItem = "{Binding SelectedDepth}"/> <!--<ListBox Name="lstDepth" ItemsSource = "{Binding depth}" SelectedItem = "{Binding SelectedDepth}"/>--> <!--<ListBox Name="lstbxDepth" Padding="5" Width="50" VerticalAlignment="Center" > <ListBoxItem Content="1"></ListBoxItem> <ListBoxItem Content="2"></ListBoxItem> <ListBoxItem Content="3"></ListBoxItem> <ListBoxItem Content="4"></ListBoxItem> </ListBox>--> <!--<TextBox x:Name="txtDepth" Text="{Binding Depth}" Padding="5" Width="50" VerticalAlignment="Center" LostFocus="OrigAcctTxt_LostFocus" />--> <!--<ListBox ItemsSource = "{Binding OrigAcctID}" SelectedItem = "{Binding SelectedStudent}"/>--> <!--<ListBox Name="lstInmateAccounts" SelectedItem = "{Binding SelectedStudent}"/>--> </StackPanel> <!-- Configuration: *CFG* - line color line color: <ig:XamNetworkNode Line="Red" --> <ig:XamNetworkNode x:Name="xnn" Background="AliceBlue" NodeControlAttachedEvent="Xnn_NodeControlAttachedEvent" HorizontalAlignment="Stretch" VerticalAlignment="Stretch" ItemsSource="{Binding Persons}" ZoomLevel="1" LineEndCap="SolidArrow" LineCapSize="10" Grid.Row="3" FontWeight="Bold" FontSize="20" SelectedNodesCollectionChanged="xnn_SelectedNodesCollectionChanged" > <!--Infragistics: ConnectionWeightMemberPath doesn't do anything yet. ConnectionWeight has no effect at this time, but we plan to implement functionality for this in the future.--> <ig:XamNetworkNode.GlobalNodeLayouts> <ig:NetworkNodeNodeLayout x:Name="xmnode" TargetTypeName="Person" NodeStyle="{StaticResource MyNodeStyle}" ConnectionsMemberPath="Connections" ConnectionTargetMemberPath="Target" ConnectionWeightMemberPath="Weight" ToolTipMemberPath="ToolTip" DisplayMemberPath="Name" /> </ig:XamNetworkNode.GlobalNodeLayouts> </ig:XamNetworkNode> <StackPanel Orientation="Vertical" Height="150" HorizontalAlignment="Right" TextBlock.TextAlignment="Justify" Grid.Row="4" > <Label Content="OPTIONS" /> <TextBlock Name="tb_DisaplayNode" Foreground="Blue"/> <Button x:Name= "btnEditAccount" Content="Back To Edit Account" Margin="1" Padding="2" Click="btnEditAccount_Click"/> <Button x:Name= "btnGenerateReport" Content="Generate Reports" Margin="1" Padding="2" Click="bth_RemoveNodeFromView_Click"/> </StackPanel> </Grid> </TabItem> <TabItem Header="Messages"> <Grid> <Grid.RowDefinitions> <RowDefinition Height="auto"/> <RowDefinition/> </Grid.RowDefinitions> <Menu Grid.Row="0"> <MenuItem Header="Clear" Command="{Binding CmdClearMessages}"> <MenuItem.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="Black" Offset="0"/> <GradientStop Color="White" Offset="1"/> </LinearGradientBrush> </MenuItem.Background> </MenuItem> </Menu> <TextBox Grid.Row="1" Background="Transparent" Text="{Binding MessageArea, Mode=OneWay}" IsReadOnly="True" VerticalAlignment="Stretch" HorizontalAlignment="Stretch" TextWrapping="Wrap" ScrollViewer.CanContentScroll="True" /> </Grid> </TabItem> </TabControl> <StatusBar Grid.Row="1" VerticalAlignment="Bottom" HorizontalAlignment="Stretch"> <Label Content="{Binding StatusMessage}" /> </StatusBar> </Grid> </UserControl>
<Grid.Resources> <!-- www.infragistics.com/.../infragisticswpf.controls.maps.xamnetworknode~infragistics.controls.maps.networknodenodecontrol_members --> <!-- Configuration: *CFG* - text color, font shadow color text color: Foreground="White" font shadow color: <DropShadowEffect Color="Black" --> <Style x:Key="MyNodeStyle" TargetType="{x:Type ig:NetworkNodeNodeControl}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ig:NetworkNodeNodeControl}"> <Grid x:Name="ButtonGrid"> <Border CornerRadius="20" Background="{Binding Color}" BorderThickness="0"> <TextBox Background="Transparent" IsReadOnly="True" Text="{Binding Name}" Padding="20" BorderThickness="0" FontSize="{Binding FontSize}" TextWrapping="Wrap" VerticalAlignment="Center" HorizontalAlignment="Center"> <TextBox.Resources> <Style TargetType="{x:Type TextBox}"> <Style.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Setter Property="Foreground" Value="Blue"/> </Trigger> <Trigger Property="IsMouseOver" Value="False"> <Setter Property="Foreground" Value="White"/> </Trigger> </Style.Triggers> </Style> </TextBox.Resources> <TextBox.Effect> <DropShadowEffect ShadowDepth="3" Color="Black" Opacity="1" BlurRadius="3" /> </TextBox.Effect> </TextBox> </Border> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>
</Grid
The above mentioned Tags for implementing style such as color,fonts and bold.
This I am binding. "MyNodeStyle" in NodeStyle="{StaticResource MyNodeStyle}" of XamNetworkNode.
Can You Please suggest some other way?
I checked this link but this is not as per my requirement.
I am storing color for each node in DB and I am using property in Model View.
and I am binding this property in style.
So, can you help me in this way. like Dynamic binding.
Thanks for the sample.Can you provide some conditional style code like
node%2= Red
else
blue
So, the color of nodes should be bind with property.
This will be helpful for me.