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
<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?
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>
<UserControl x:Class="XamNetworkNode.MainWindow"
xmlns="">schemas.microsoft.com/.../presentation"
xmlns:x="">schemas.microsoft.com/.../xaml"
xmlns:d="">schemas.microsoft.com/.../2008"
xmlns:mc="">schemas.openxmlformats.org/.../2006"
xmlns:local="clr-namespace:XamNetworkNode"
xmlns:ig="">schemas.infragistics.com/xaml"
mc:Ignorable="d"
Height="450" Width="800">
<!--<UserControl.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="Skins/MainSkin.xaml" />
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</UserControl.Resources>-->
<Grid VerticalAlignment="Stretch">
<!--<Grid.Resources>
<local:SimpleGraphData x:Key="GraphData" />
</Grid.Resources>-->
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition Height="auto"/>
</Grid.RowDefinitions>
<Grid x:Name="LayoutRoot">
<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"/>
</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>
</Grid.Resources>
<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}" />
<!--<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" />
<!--<Label Content="Depth" VerticalAlignment="Center"/>-->
<Label Content="Depth" VerticalAlignment="Center"/>
<TextBox x:Name="txtDepth" Text="{Binding Depth}" Padding="5" Width="50" VerticalAlignment="Center" />
<!--<ComboBox x:Name = "cmbDepth" Margin="5" Padding="5" Width="50" ItemsSource = "{Binding depth}" SelectedItem = "{Binding SelectedDepth}"/>-->
</StackPanel>
<ig:XamNetworkNode x:Name="xnn" SelectedNodesCollectionChanged="xnn_SelectedNodesCollectionChanged" SelectionType="Single"
ItemsSource="{Binding Persons}">
<ig:XamNetworkNode.GlobalNodeLayouts>
<ig:NetworkNodeNodeLayout
TargetTypeName = "Person"
DisplayMemberPath = "Name"
ToolTipMemberPath = "ToolTip"
ConnectionsMemberPath = "Connections"
ConnectionTargetMemberPath = "Target"
ConnectionWeightMemberPath="Weight"
NodeStyle="{StaticResource MyNodeStyle}"
/>
</ig:XamNetworkNode.GlobalNodeLayouts>
</UserControl>
Here is .xaml Design code
When I removed this then event is working fine but I need to add this code also for formatting
Can you please suggest any good way?