Example #1
0
        public void SetRecentItems()
        {
            try
            {
                recentProjects.Items.Clear();

                BindingList <License> lics = UIContext.GetLatestLicenses();

                SeparatorTabItem separator = new SeparatorTabItem();
                separator.Header = "Recent Projects";
                recentProjects.Items.Add(separator);

                foreach (var license in lics)
                {
                    TabItem tb = new TabItem();
                    tb.Header            = license.Name;
                    tb.Name              = string.Format("License_{0}", license.LicenseId.ToString());
                    tb.MouseDoubleClick += new System.Windows.Input.MouseButtonEventHandler(b_MouseDoubleClick);

                    Grid g = new Grid();
                    g.RowDefinitions.Add(new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    });
                    g.RowDefinitions.Add(new RowDefinition());
                    g.RowDefinitions.Add(new RowDefinition());
                    g.RowDefinitions.Add(new RowDefinition {
                        Height = new GridLength(1, GridUnitType.Auto)
                    });

                    TextBlock tb1 = new TextBlock {
                        Text = string.Format("Project Name: {0}", license.Name)
                    };
                    tb1.SetValue(Grid.RowProperty, 0);

                    g.Children.Add(tb1);

                    System.Windows.Controls.Button b = new System.Windows.Controls.Button();
                    b.Content = "Open This Project";
                    b.Name    = string.Format("License_{0}", license.LicenseId.ToString());
                    b.Click  += new System.Windows.RoutedEventHandler(btn_Click);
                    b.SetValue(Grid.RowProperty, 3);

                    g.Children.Add(b);
                    tb.Content = g;
                    recentProjects.Items.Add(tb);
                }
            }
            catch (Exception ex) { }
        }