"The name does not exist in the namespace" in XAML designer - c#

I'm trying bind my Classes to HierarchicalDataTemplate. See code below.
XAML
<Window x:Name="window" x:Class="MyCompany.Press.MainWindow"
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:helpers="clr-namespace:MyCompany.Press.Helpers"
xmlns:press="clr-namespace:MyCompany.Press"
mc:Ignorable="d"
Title="Press analyzer" Height="500" Width="800.5" ContentRendered="WindowContentRenderedEventHendler" Closing="WindowClosingEventHandler"
d:DataContext="{d:DesignData MainWindow}">
<Grid Name="MainGrid">
...
<TreeView Name="ArticlesTreeView" Grid.Column="0" AllowDrop="True" >
<TreeView.Resources>
<HierarchicalDataTemplate DataType="{x:Type press:NewsPaperDocument}" ItemsSource="{Binding Children}">
<TextBlock Text="{Binding Name}" Tag="{Binding Object}" FontWeight="Bold" />
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type press:NewsPaperPage}" ItemsSource="{Binding Children}">
<TextBlock Text="{Binding Name}" Tag="{Binding Object}" Foreground="#00a300" />
</HierarchicalDataTemplate>
<HierarchicalDataTemplate DataType="{x:Type press:NewsPaperTitle}" ItemsSource="{Binding Children}">
<TextBlock Text="{Binding Name}" Tag="{Binding Object}" Foreground="#da532c" />
</HierarchicalDataTemplate>
<DataTemplate DataType="{x:Type press:NewsPaperBlock}">
<TextBlock Text="{Binding Name}" Tag="{Binding Object}" Foreground="#2b5797" />
</DataTemplate>
</TreeView.Resources>
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<!-- Style for the selected item -->
<Setter Property="BorderThickness" Value="1" />
<Style.Triggers>
<!-- Selected and has focus -->
<Trigger Property="IsSelected" Value="True">
<Setter Property="BorderBrush" Value="#7DA2CE" />
</Trigger>
<!-- Mouse over -->
<Trigger Property="helpers:TreeViewHelper.IsMouseDirectlyOverItem" Value="True">
<Setter Property="Background">
<Setter.Value>
<LinearGradientBrush EndPoint="0,1" StartPoint="0,0">
<GradientStop Color="#FFFAFBFD" Offset="0" />
<GradientStop Color="#FFEBF3FD" Offset="1" />
</LinearGradientBrush>
</Setter.Value>
</Setter>
<Setter Property="BorderBrush" Value="#B8D6FB" />
</Trigger>
<!-- Selected but does not have the focus -->
...
</Style.Triggers>
<Style.Resources>
<Style TargetType="Border">
<Setter Property="CornerRadius" Value="2" />
</Style>
</Style.Resources>
</Style>
</TreeView.ItemContainerStyle>
</TreeView>
</Grid>
</Grid>
</Window>
If I use x:Type, designer say
Design view is unavailable for x64 and ARM target platforms.
and error like
The name "NewsPaperDocument" does not exist in the namespace "clr-namespace:MyCompany.Press"
but code compile and run completely.
Same error I have on <Trigger Property="helpers:TreeViewHelper.IsMouseDirectlyOverItem" Value="True"> line.
If I remove x:Type designer works fine, but HierarchicalDataTemplate doesn't work correctly
P.S. TreeViewHelper I get here http://blogs.msdn.com/b/mikehillberg/archive/2006/09/21/mytreeviewhelperismousedirectlyoveritem.aspx

Related

I am unable to make a ContentControl a region using Prism

I'm building a prism application and I've setup the shell with a hamburgermenu from MahApps. Within the content of that Hamburgermenu I would like to have a region.
But when I try to make a region out of a ContentControl within "Hamburgermenu.Content" the region is not added.
However, if I try to make a region out of a ContentControl OUTSIDE the Hamburgermenu-control, it works perfectly.
<Controls:MetroWindow x:Class="SystemCreator.ClientApplication.MainWindow"
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:local="clr-namespace:SystemCreator.ClientApplication"
xmlns:Controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"
xmlns:iconPacks="http://metro.mahapps.com/winfx/xaml/iconpacks"
xmlns:converters="http://metro.mahapps.com/winfx/xaml/shared"
xmlns:prism="http://prismlibrary.com/"
xmlns:inf="clr-namespace:SystemCreator.ClientApplication.Infrastructure;assembly=SystemCreator.ClientApplication.Infrastructure"
xmlns:cdviews="clr-namespace:SystemCreator.CreateDatabase;assembly=SystemCreator.CreateDatabase"
xmlns:test="clr-namespace:TestModule;assembly=TestModule"
prism:ViewModelLocator.AutoWireViewModel="True"
mc:Ignorable="d"
Title="{Binding Title}" Height="450" Width="800">
<Window.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="pack://application:,,,/MahApps.Metro;component/Themes/HamburgerMenuTemplate.xaml" />
</ResourceDictionary.MergedDictionaries>
<Style x:Key="MahApps.Metro.Styles.HamburgerMenu" TargetType="{x:Type Controls:HamburgerMenu}">
<Setter Property="FocusVisualStyle" Value="{x:Null}" />
<Setter Property="Focusable" Value="False" />
<Setter Property="HamburgerMenuTemplate">
<Setter.Value>
<DataTemplate>
<!-- PackIconMaterial - Menu -->
<ContentControl Width="22"
Height="22"
Content="M3,6H21V8H3V6M3,11H21V13H3V11M3,16H21V18H3V16Z"
Style="{DynamicResource PathIconContentControlStyle}" />
</DataTemplate>
</Setter.Value>
</Setter>
<Setter Property="HorizontalAlignment" Value="Stretch" />
<Setter Property="ItemContainerStyle" Value="{StaticResource HamburgerMenuItemStyle}" />
<Setter Property="KeyboardNavigation.ControlTabNavigation" Value="Local" />
<Setter Property="KeyboardNavigation.DirectionalNavigation" Value="Local" />
<Setter Property="KeyboardNavigation.TabNavigation" Value="Local" />
<Setter Property="OptionsItemContainerStyle" Value="{StaticResource HamburgerMenuItemStyle}" />
<Setter Property="PaneBackground" Value="{DynamicResource MahApps.Metro.HamburgerMenu.PaneBackgroundBrush}" />
<Setter Property="PaneForeground" Value="{DynamicResource MahApps.Metro.HamburgerMenu.PaneForegroundBrush}" />
<Setter Property="Template" Value="{StaticResource HamburgerMenuTemplate}" />
<Setter Property="VerticalContentAlignment" Value="Stretch" />
</Style>
<DataTemplate x:Key="MenuItemTemplate" DataType="{x:Type
Controls:HamburgerMenuIconItem}">
<Grid Height="48">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="48" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<ContentControl Grid.Column="0"
HorizontalAlignment="Center"
VerticalAlignment="Center"
Content="{Binding Icon}"
Focusable="False"
IsTabStop="False" />
<TextBlock Grid.Column="1"
VerticalAlignment="Center"
FontSize="16"
Text="{Binding Label}" />
</Grid>
</DataTemplate>
</ResourceDictionary>
</Window.Resources>
<Controls:HamburgerMenu x:Name="HamburgerMenuControl"
Grid.Column="0"
Grid.ColumnSpan="2"
Grid.Row="1"
HamburgerWidth="48"
DisplayMode="CompactInline"
VerticalScrollBarOnLeftSide="False"
ItemTemplate="{StaticResource MenuItemTemplate}"
OptionsItemTemplate="{StaticResource MenuItemTemplate}"
Style="{StaticResource MahApps.Metro.Styles.HamburgerMenu}"
Width="Auto"
>
<Controls:HamburgerMenu.HamburgerMenuHeaderTemplate>
<DataTemplate>
<TextBlock HorizontalAlignment="Center"
VerticalAlignment="Center"
FontSize="16"
Foreground="White"
Text="Menu" />
</DataTemplate>
</Controls:HamburgerMenu.HamburgerMenuHeaderTemplate>
<!--Content-->
<Controls:HamburgerMenu.Content>
<ContentControl prism:RegionManager.RegionName="{x:Static inf:ApplicationConstants.MainContent}" />
</Controls:HamburgerMenu.Content>
</Controls:HamburgerMenu>
</Grid>
</Controls:MetroWindow>
Since the region is not added while inside the Hamburgermenu, the navigation is not working. Do anyone have an idea on what i might have done wrong?
The attached property (RegionManager.RegionName) does only work for controls created immediately. Lazily created controls will not be detected, because the region manager is done looking for regions.
You need to add the region manually, in the menu's code behind (constructor), like this:
RegionManager.SetRegionName( theNameOfTheContentControlInsideTheMenu, WellKnownRegionNames.MenuRegion );
RegionManager.SetRegionManager( theNameOfTheContentControlInsideTheMenu, theRegionManager );
You'll have to assign a name to the content control hosting the region and somehow acquire the region manager (ServiceLocator.Current.GetInstance<IRegionManager>()).

How to apply App.XAML style to current window

I am trying to apply validation error template and defining style in App.XAML.
<Application x:Class="MY.UI.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:BP.NES.UI"
>
<Application.Resources>
<Style TargetType="{x:Type TextBox}">
<Setter Property="Validation.ErrorTemplate">
<Setter.Value>
<ControlTemplate>
<Grid>
<Border BorderBrush="#FFCB2E2E" BorderThickness="1" Background="#11FF0000" IsHitTestVisible="False" x:Name="errorBorder"/>
<AdornedElementPlaceholder x:Name="placeholder" />
<Popup AllowsTransparency="True" HorizontalAlignment="Right" HorizontalOffset="0" VerticalOffset="0" PopupAnimation="Fade" Placement="Left"
PlacementTarget="{Binding ElementName=errorBorder}" IsOpen="{Binding ElementName=placeholder, Path=AdornedElement.IsFocused, Mode=OneWay}">
<StackPanel Orientation="Horizontal">
<Polygon VerticalAlignment="Center" Points="0,4 4,0 4,8" Fill="#FFCB2E2E" Stretch="Fill" Stroke="#FFCB2E2E"
StrokeThickness="2" />
<Border Background="#FFCB2E2E" CornerRadius="4" Padding="4">
<TextBlock HorizontalAlignment="Center" Foreground="White" FontWeight="Bold" Margin="2,0,0,0"
Text="{Binding ElementName=placeholder, Path=AdornedElement.ToolTip, Mode=OneWay}" />
</Border>
</StackPanel>
</Popup>
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
<Style.Triggers>
<Trigger Property="Validation.HasError" Value="True">
<Setter Property="ToolTip" Value="{Binding RelativeSource={RelativeSource Self}, Path=(Validation.Errors)[0].ErrorContent}" />
</Trigger>
</Style.Triggers>
</Style>
</Application.Resources>
</Application>
Now in My Main Window I have following code:
<Window x:Class="MY.UI.View.MainWindow"
xmlns:local="clr-namespace:MY.UI.View"
xmlns:sys="clr-namespace:System;assembly=mscorlib"
mc:Ignorable="d"
xmlns:vm="clr-namespace:MY.UI.ViewModel"
xmlns:rules="clr-namespace:MY.UI.Validations"
>
<Grid x:Name="MainGrid">
<TextBox Grid.Row="1"
x:Name="CellphoneNumberTextBox"
Grid.Column="1"
VerticalAlignment="Stretch"
Margin="10,0,0,10"
IsEnabled="{Binding ElementName=PereferenceRadio,Path=IsChecked}"
Text="{Binding CurrentEnrolmentDetail.CellNumber,NotifyOnValidationError=True,ValidatesOnNotifyDataErrors=True,UpdateSourceTrigger=PropertyChanged}">
</TextBox>
</Grid>
</Window>
If I move style to Window.Resources, it just works fine ,but when I have this in App.XAML , does not work. Is this due to difference in namespace?
Set a style key in App.Xaml and use the key in your Textbox.
Example:
App.Xaml
<Style x:Key="HeaderStyle" TargetType="TextBlock">
<Setter Property="Foreground" Value="Gray" />
<Setter Property="FontSize" Value="24" />
</Style>
Window:
<Window x:Class="WpfTutorialSamples.Styles.ExplicitStyleSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="ExplicitStyleSample" Height="150" Width="300">
<StackPanel Margin="10">
<TextBlock>Header 1</TextBlock>
<TextBlock Style="{StaticResource HeaderStyle}">Header 2</TextBlock>
<TextBlock>Header 3</TextBlock>
</StackPanel>
</Window>
Or Override using BasedOn functionality
Try this if you don't have interest to create style key
App.Xaml
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
<!-- ... -->
</Style>
I have declared my base styles in a ResourceDictionary in App.xaml, if i override them in a specific window like this, it usually works.
If all TextBox will remain similar thought application than use following in resource file.
<Style TargetType="{x:Type TextBox}" BasedOn="{StaticResource {x:Type TextBox}}">
<Setter Property="Background" Value="Blue"/>
</Style>
Else create key in App.xaml and use in the TextBox's where required as shown below:
<Style x:Key="TextboxBackgroundColor" TargetType="TextBox">
<Setter Property="Background" Value="Cyan"/>
</Style>
<TextBox x:Name="txtText" Style="{StaticResource TextboxBackgroundColor}" />

WPF TreeView How to make trigger for IsSelected of treeViewItem

The following code is treeview:
<TreeView BorderThickness="1,1,1,1" BorderBrush="#ffcccccc" HorizontalAlignment="Stretch" VerticalAlignment="Stretch"
ItemTemplate="{StaticResource itemTypeTreeViewTemplate}"
ItemsSource="{Binding ItemTypes}"
ItemContainerStyle="{StaticResource treeViewItemStyle}"/>
And i set the itemTemplate to set the binding of items. Then set the ItemContainerStyle to change IsSelected style:
<Style x:Key="treeViewItemStyle" TargetType="TreeViewItem">
<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="LightBlue" />
</Trigger>
</Style.Triggers>
</Style>
<HierarchicalDataTemplate x:Key="itemTypeTreeViewTemplate"
ItemsSource="{Binding Child}">
<DockPanel Margin="0,5,0,5">
<Button VerticalAlignment="Center"
x:Name="btn1" Width="25"
Visibility="{Binding Path=IsMouseOver,RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource BooleanToVisibilityConverter }}"
Content="U" DockPanel.Dock="Right" cal:Message.Attach="[Event Click] = [Action EditItemType($dataContext)]"
Style="{StaticResource ButtonStyle1}" />
<TextBlock Margin="0,2,0,2" VerticalAlignment="Center" Text="{Binding ItemTypeName}" Foreground="#FF2e8bcc" FontSize="10" FontFamily="微软雅黑" />
</DockPanel>
</HierarchicalDataTemplate>
But the isSelected style is not work. Anybody find the key??
Instead of using a style trigger, you should override the colour key for the highlighted state. Here's the code:
<Style x:Key="treeViewItemStyle" TargetType="TreeViewItem">
<!--<Style.Triggers>
<Trigger Property="IsSelected" Value="True">
<Setter Property="Background" Value="LightBlue" />
</Trigger>
</Style.Triggers>--><!--Remove Style.Trigger block-->
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}"
Color="LightBlue"/>
</Style.Resources>
</Style>
Hope this helps. The other keys for this control are:
HighlightBrushKey - Focussed background. (Is focussed when
selected)
HighlightTextBrushKey - Focussed foreground.
InactiveSelectionHighlightBrushKey - Normal background.
InactiveSelectionHighlightTextBrushKey - Normal foreground.

Applying a Custom Template for TextBox Header

I am developing a windows phone app and my requirements include to use a specific color theme and not use the default theme (Light/Dark/etc.) of the phone.
I'm stuck at formatting/templating the headers of textboxes. The following code in the app.xaml is not working:
<DataTemplate x:Key="HeaderTemplate">
<TextBlock Text="{Binding}" Foreground="Black"/>
</DataTemplate>
<Style TargetType="TextBox">
<Setter Property="Foreground" Value="#FFBBB8B8"/>
<Setter Property="BorderBrush" Value="LightGray"/>
<Setter Property="HeaderTemplate" Value="{StaticResource HeaderTemplate}"/>
</Style>
Is there either a way just to configure the theme used or a way to implement the template for the headers?
If you need to implement a Template on a Page
<Page.Resources>
<Style TargetType="TextBox">
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<Grid>
<TextBlock Text="{Binding}" Foreground="Red" />
</Grid>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
</Page.Resources>
<StackPanel>
<TextBox x:Name="TextBox" Width="300" Height="80"
Margin="20" Header="Headline"/>
<TextBox x:Name="TextBox2" Width="300" Height="80"
Margin="20" Header="Headline2"/>
</StackPanel>
or if you want the Style to apply to certain TextBox give it a Key
<Style TargetType="TextBox" x:Key="MyTextBoxStyle">
and apply to relevant TextBox
<TextBox x:Name="TextBox2" Width="300" Height="80"
Margin="20" Header="Headline2"
Style="{StaticResource MyTextBoxStyle}"/>}"/>
Hope that helps
It is really strange I tested the following:
<Application.Resources>
<Style TargetType="TextBox" >
<Setter Property="Foreground" Value="#FFBBB8B8"/>
<Setter Property="BorderBrush" Value="LightGray"/>
<Setter Property="HeaderTemplate">
<Setter.Value>
<DataTemplate>
<TextBlock Foreground="Red" Text="testing"/>
</DataTemplate>
</Setter.Value>
</Setter>
</Style>
<DataTemplate x:Key="DT1">
<TextBlock Foreground="Green" Text="testing"/>
</DataTemplate>
<Style TargetType="TextBox" x:Key="TextBoxStyle2">
<Setter Property="Foreground" Value="#FFBBB8B8"/>
<Setter Property="BorderBrush" Value="LightGray"/>
<Setter Property="HeaderTemplate" Value="{StaticResource DT1}"/>
</Style>
</Application.Resources>
and in the mainpage
<Grid>
<TextBox Text="testing"/>
<TextBox Margin="0,100,0,0" Style="{StaticResource TextBoxStyle2}" Text="testing"/>
</Grid>
And it works, so I think the content from the binding is empty and appears not be working.

WPF Listbox selected item brings up another sub listbox items

I have a unique request and I am very new to WPF.
I have a list of Items. When I select an Item, it should show the child items.
There are many ways to do this:
1. You have the sub listbox items slide down moving the parent listbox items down. There will be lot of bouncing around
2. To avoid the height change, I am thinking that the sub listbox items can popup and I select the child items. If not, then I click away and get back to my parent listbox items.
I have no idea where to begin adding a sub listbox items underneath it's parent listbox item.
I have two listbox in my xaml
<Window x:Class="MakeModel.MakeModelYear"
Icon="cc_64x64_blue_02.ico"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:MakeModel"
Title="Car Make and Model" Height="740.667" Width="426" Opacity="0.9"
WindowStartupLocation="CenterScreen" ResizeMode="CanResize" Background="White">
<Window.Resources>
</Window.Resources>
<Grid>
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="#FFFFFE" Offset="0"/>
<GradientStop Color="#FF6699CC" Offset="1.2"/>
</LinearGradientBrush>
</Grid.Background>
<Grid.RowDefinitions>
<RowDefinition Height="156*"/>
<RowDefinition/>
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="0*"/>
<ColumnDefinition Width="53*"/>
<ColumnDefinition Width="198*"/>
</Grid.ColumnDefinitions>
<StackPanel Margin="0,31,0,29" Grid.ColumnSpan="3">
<GroupBox Header="Make / Model" BorderBrush="WhiteSmoke" BorderThickness="0" Margin="5,0" Foreground="#FF0B6C78" FontSize="18" FontFamily="Microsoft Sans Serif">
<!--Task -->
<StackPanel>
<ListBox x:Name="cmbMake" HorizontalAlignment="Left" VerticalAlignment="Top" Width="387" Cursor="Arrow"
ItemsSource="{Binding SelectedMake}" DisplayMemberPath ="Make"
SelectionChanged="cmbMake_SelectionChanged" SelectionMode="Single" RenderTransformOrigin="0.494,1.409" Margin="0,3,0,0" Height="150" BorderBrush="#FF336699" FontFamily="Microsoft Sans Serif" FontSize="12" >
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="Transparent"/>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
</Style.Resources>
<EventSetter Event="UIElement.MouseEnter" Handler="cmbFirstDigitLineItem_MouseMove" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True" >
<Setter Property="Background" Value="#FFD7E1EC" />
</Trigger>
<Trigger Property="IsSelected" Value="True" >
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="FontSize" Value="24" />
<Setter Property="Foreground" Value="Black" />
</Trigger>
</Style.Triggers>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.Template>
<ControlTemplate>
<Border CornerRadius="5" BorderThickness="0" BorderBrush="#FF336699">
<ItemsPresenter/>
</Border>
</ControlTemplate>
</ListBox.Template>
</ListBox>
</StackPanel>
</GroupBox>
</StackPanel>
<StackPanel Margin="0,205,0,29" Grid.ColumnSpan="3">
<GroupBox Header="" BorderBrush="WhiteSmoke" BorderThickness="0" Margin="5,0">
<!--Subtask -->
<StackPanel>
<ListBox x:Name="cmbModel" HorizontalAlignment="Left" VerticalAlignment="Top" Width="387" Cursor="Arrow"
ItemsSource="{Binding SelectedModel}" DisplayMemberPath ="Model"
SelectionChanged="cmbModel_SelectionChanged" SelectionMode="Single" RenderTransformOrigin="0.494,1.409" Margin="0,3,0,0" Background="#FFE0E0E0" BorderBrush="#FF336699" FontFamily="Arial">
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Style.Resources>
<SolidColorBrush x:Key="{x:Static SystemColors.InactiveSelectionHighlightBrushKey}" Color="Transparent"/>
<SolidColorBrush x:Key="{x:Static SystemColors.HighlightBrushKey}" Color="Transparent"/>
</Style.Resources>
<EventSetter Event="UIElement.MouseEnter" Handler="cmbSecondDigitLineItem_MouseMove" />
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True" >
<Setter Property="Background" Value="#FFD7E1EC" />
</Trigger>
<Trigger Property="IsSelected" Value="True" >
<Setter Property="FontWeight" Value="Bold" />
<Setter Property="FontSize" Value="24" />
<Setter Property="Background" Value="Transparent" />
<Setter Property="Foreground" Value="Black" />
</Trigger>
</Style.Triggers>
</Style>
</ListBox.ItemContainerStyle>
<ListBox.Template>
<ControlTemplate>
<Border CornerRadius="5" BorderThickness="0" BorderBrush="#FF336699">
<ItemsPresenter/>
</Border>
</ControlTemplate>
</ListBox.Template>
</ListBox>
</StackPanel>
</GroupBox>
</StackPanel>
</Grid>
</Window>
Well, let me try to explain in plain and simple English :)
First, you should have your classes something like this:
public class Foo{
public ObservableCollection<MyParentObject> ListToBind {get;set;}
.... (rest of properties)
}
public class MyParentObject{
public ObservableCollection<MyChildObject> ChildListToBind {get;set;}
.... (rest of properties)
}
Then in your XAML you can have something like this:
And then as Window or UserControl Resources you have:
<DataTemplate x:key="listItemTemplate">
<Grid>
<ListBox ItemsSource={Binding ChildListToBind}" ItemTemplate="........"/>
</Grid>
</DataTemplate>
This is not perfect code...but hope it gives you head start to what you want.
Regards,

Categories