You can try the following code: it use mouseEnter event to trigger menu action:
Page.XAML:
<UserControl x:Class="Page"
xmlns="http://schemas.microsoft.com/client/2007"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>
<Grid>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="200" />
<ColumnDefinition />
</Grid.ColumnDefinitions>
<!-- Menu -->
<ListBox x:Name="MenuList">
<ListBox.ItemTemplate>
<DataTemplate>
<Border x:Name="Menu" HorizontalAlignment="Stretch" MouseEnter="Menu_MouseEnter" Loaded="Menu_Loaded" Background="Transparent" Cursor="Hand">
<TextBlock Text="{Binding Text}"/>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<!-- Content Container -->
<Grid Grid.Column="1" Margin="5,0,5,0" ShowGridLines="False" Background="White">
<Border BorderThickness="1" BorderBrush="#ccc">
<Grid x:Name="ContentContainer" Margin="5">
<TextBlock>Control Detail</TextBlock>
</Grid>
</Border>
</Grid>
</Grid>
</UserControl>
Page.XAML.cs:
namespace YourNameSpace
{
public partial class Page: UserControl
{
public Page()
{
InitializeComponent();
List<MenuData> list = new List<MenuData>();
list.Add(new MenuData { Text = "Menu Item 1", Url = "http://silverlight.net/Samples/2b1/SilverlightControls/run/default.html" });
list.Add(new MenuData { Text = "Menu Item 2", ControlType = typeof([UserControl you want to put to the page content area]).FullName });
list.Add(new MenuData { Text = "Menu Item 3" });
MenuList.ItemsSource = list;
}
private void Menu_Loaded(object sender, RoutedEventArgs e)
{
//This is a workaround for a bug in ListBox in SL2 beta, The ListItem won't Stretch to the full length.
FrameworkElement g = sender as FrameworkElement;
g.Width = MenuList.ActualWidth;
}
private void Menu_MouseEnter(object sender, MouseEventArgs e)
{
FrameworkElement g = sender as FrameworkElement;
MenuData m = g.DataContext as MenuData;
if (m != null)
{
if (m.ControlType != null)
{
UIElement o = this.GetType().Assembly.CreateInstance(m.ControlType) as UIElement;
ContentContainer.Children.RemoveAt(0);
ContentContainer.Children.Add(o);
}
else if (m.Url != null)
{
HtmlPage.Window.Navigate(new Uri(m.Url), "_blank");
}
else
{
//do something you want.
}
}
}
}
}
ManuData.cs - just the code, no XAML . This is the Data object for holding MenuData
public class MenuData
{
public string MenuText { get; set; }
public string ControlType { get; set; }
public string Url { get; set; }
}
Software Engineer
Aprimo, Inc
Please remember to mark the replies as answers if they answered your question