public Window CreateWindow() { // Create a window object and set its size to the // size of the display. mainWindow = new Window(); mainWindow.Height = SystemMetrics.ScreenHeight; mainWindow.Width = SystemMetrics.ScreenWidth; // Add a gradient color background to the window mainWindow.Background = new LinearGradientBrush(Colors.White, Colors.Red, 0, 0, mainWindow.Width, mainWindow.Height); Font font = Resources.GetFont(Resources.FontResources.NinaB); // Create a list box control and add text items ListBox listBox = new ListBox(); // set the width so that it fills the entire screen listBox.Child.Width = mainWindow.Width; // make the list box transparent listBox.Background = null; // make the enclosed scroll viewer transparent also // we get the scroll viewer via the child property but // need to cast it to Control in order to clear the background ((Control)listBox.Child).Background = null; for (int i = 0; i < 10; ++i) { string str = "Item " + i.ToString() + ". Hello World."; ListBoxItem item = new HighlightableTextListBoxItem(font, str); listBox.Items.Add(item); if (i > 0 && i % 4 == 0) listBox.Items.Add(new SeparatorListBoxItem()); } // Add the text control to the window. mainWindow.Child = listBox; // Set the window visibility to visible. mainWindow.Visibility = Visibility.Visible; // Let the user select items with the up and down buttons. Buttons.Focus(listBox); // Get notified when the selected item was changed. listBox.SelectionChanged += new SelectionChangedEventHandler(listBox_SelectionChanged); // Get notified when a selected item was pressed // using the select button. listBox.AddHandler(Buttons.ButtonDownEvent, new ButtonEventHandler(listBox_ButtonDown), false); return mainWindow; }
public Window CreateWindow() { // Create a window object and set its size to the // size of the display. mainWindow = new Window(); mainWindow.Height = SystemMetrics.ScreenHeight; mainWindow.Width = SystemMetrics.ScreenWidth; Font font = Resources.GetFont(Resources.FontResources.NinaB); // Create a list box control and add text items ListBox listBox = new ListBox(); for (int i = 0; i < 10; ++i) { string str = "Item " + i.ToString() + ". Hello World."; ListBoxItem item = new HighlightableTextListBoxItem(font, str); listBox.Items.Add(item); if (i > 0 && i % 4 == 0) listBox.Items.Add(new SeparatorListBoxItem()); } // Add the text control to the window. mainWindow.Child = listBox; // Set the window visibility to visible. mainWindow.Visibility = Visibility.Visible; // Let the user select items with the up and down buttons. Buttons.Focus(listBox); // Get notified when the selected item was changed. listBox.SelectionChanged += new SelectionChangedEventHandler(listBox_SelectionChanged); // Get notified when a selected item was pressed // using the select button. listBox.AddHandler(Buttons.ButtonDownEvent, new ButtonEventHandler(listBox_ButtonDown), false); return mainWindow; }