Ejemplo n.º 1
0
        public override void OnApplyTemplate()
        {
            base.OnApplyTemplate();

            // We are ready to retreive controls from the template
            this.listBox = this.GetTemplateChild("listBox") as ListBox;
            listBox.ItemsSource = ItemSource;

            this.titleTextBlock = this.GetTemplateChild("DialogTitle") as TextBlock;
            // Assign the values
            this.ItemSource = itemSource;
            this.Title = title;
            if (this.ItemSource != null)
            {
                SelectedIndex = selectedIndex;

                if (listBox.SelectedItem != null)
                    listBox.SetVerticalScrollOffset(SelectedIndex);
            }
            listBox.Opacity = 0;
            // Hook up into listbox's events
            this.listBox.SelectionChanged += new SelectionChangedEventHandler(listBox_SelectionChanged);
            this.listBox.Loaded += new RoutedEventHandler(listBox_Loaded);
            this.listBox.SelectionMode = SelectionMode.Multiple;
        }