/// <summary> /// Initializes a new instance of the ContextMenuSample class. /// </summary> public ContextMenuSample() { InitializeComponent(); // Initialize variables EmailBody.DataContext = this; ChangeFontFaceCommand = new ChangeControlFontFaceCommand(EmailBody); ChangeFontSizeCommand = new ChangeControlFontSizeCommand(EmailBody); // Suppress Silverlight right-click menu for clicks on ListBoxItem elements EmailList.MouseRightButtonDown += delegate(object sender, MouseButtonEventArgs e) { e.Handled = true; }; // Create sample emails for (int i = 1; i < 16; i++) { _emails.Add(new Email { Subject = "Email Number " + i, Body = CreateRandomText(_rand.Next(20, 300)) }); } EmailList.ItemsSource = _emails; // Select the top email EmailList.SelectedIndex = 0; }