new_TreeViewExample.png

The Tree View allows changing the color(s) of the tree arrow that toggles: expanded vs. collapsed. This method currently is overloaded with parameters to set pressed color and selected color for the entire TreeViewItem as well . . .
trv.SetArrowColors("PowderBlue", "Purple", "Black", "Blue", "Purple", "Black", 20, 23, "LightBlue", "White", "Khaki", "Black");

Two other important color-related settings are the normal background and foreground.
TreeViewExt.SetTreeViewItemBackgroundColor(trv, Brushes.PowderBlue);
TreeViewExt.SetTreeViewItemForegroundColor(trv, Brushes.Black);

FULL TREE VIEW EXAMPLE
#region TreeView

            trv.Name = "myTreeView";
            
            //Add TreeView to Grid at row 1 column 0
            myGrid.BeginComposite<Grid>(gridguid4)
                .AddExisting<TreeView, Grid>(0, 0, trv)
                .EndComposite<Grid, GridArgs>(new GridArgs(1, 0));

            myGrid.UnsubscribeMouseDoubleClickByKey(gridguid4);
            myGrid.Background = Brushes.WhiteSmoke;
            trv.Initialize(428D, 430, ContainerType.Grid, 7, 3);
            trv.SetBackgroundColor(Brushes.WhiteSmoke);
         // trv.SelectedItemChanged+=trv_SelectedItemChanged;

            trv.SetCompositeGridDimensionsWithRowHt<TreeView>(3, 2, .37D, GridUnitType.Star, 279D, GridUnitType.Pixel, colWidth2: 93D, unitType2: GridUnitType.Pixel);

            TreeViewExt.SetTreeViewItemBackgroundColor(trv, Brushes.PowderBlue);
            TreeViewExt.SetTreeViewItemForegroundColor(trv, Brushes.Black);
            trv.SetArrowColors("PowderBlue", "Purple", "Black", "Blue", "Purple", "Black", 20, 23, "LightBlue", "White", "Khaki", "Black");
           
            trv.BeginSettings<TreeView>()              
                .CreateFontStyleKey("mainFont", "Segoe UI", 27D, FontWeights.Bold, FontStyles.Normal)
                .CreateColorStyleKey("mainColor", Brushes.DarkBlue) //143, 121, 100, 255)
                .SetItemBorderSettings(375D, 57D, Brushes.Purple, new Thickness(2))
                .SetFont<TreeView>(0, 0, "Verdana", 14D, FontWeights.Bold, FontStyles.Oblique, TextDecorations.Underline)
                .SetTextColor<TreeView>(0, 0, Brushes.DarkBlue)

             //   .SetItemBorderColorAndThickness(Brushes.MidnightBlue, new Thickness(0, 0, 1, 0))
                    //.SetGridProperties(3, 3, 29, GridUnitType.Pixel, 95, GridUnitType.Pixel, 310, GridUnitType.Pixel)      
                    //.SetRowPadding(new Thickness(10, 10, 10, 10))
                    //.SetScrollViewerPadding(new Thickness(10, 10, 10, 10)) 
                //.SetImageMargin(0, 0, new Thickness(0, 0, 0, 0))
               // .SetImageStretch(0, 0, Stretch.Fill)
              //  .SetImageHorizontalAlignment(0, 0, HorizontalAlignment.Left)
                 .SetTextPadding(0, 0, new Thickness(3, 0, 1, 0))
                 .SetTextPadding(1, 0, new Thickness(3, 0, 1, 0))
                 .SetTextPadding(2, 0, new Thickness(3, 0, 1, 2))
                  .Set<TextBlock, TreeView>(2, 0, "Margin", new Thickness(0, 0, 0, 2))
                 .SubscribeEventOnParent<TreeView>("SelectedItemChanged", new RoutedPropertyChangedEventHandler<object>(
                     (sender, e) => { MessageBox.Show("Selected Item Changed " + e.Source.ToString()); }))
                   // .SubscribeMouseDoubleClick(new MouseButtonEventHandler(my_MouseDoubleClick), item => { return item.GetText<ListBox>(1, 0).Contains("Lake"); })
                    //change this to use Rx and follow same IDisposable pattern?  Wire into Dispose method call?!?
                    //    .SubscribeSelectionChanged(new SelectionChangedEventHandler(myTreeView_SelectionChanged));
                    
                    ////VERTICAL SCROLLBAR
                .SetVerticalScrollBarColor(Brushes.WhiteSmoke)
                .SetVerticalScrollUpButtonColors("White", "Orange", "White", "#0088FF", "#DDDDDD", "0", "Gray", new Thickness(1), "Black", "Orange", "M 0 4 L 7 4 L 3.5 0 Z")
                .SetVerticalPageUpButtonColors("#DDDDDD", "Gray", "Gray", "#DDDDDD") //, "2", "White", new Thickness(3, 3, 3, 3))
                .SetVerticalPageDownButtonColors("#DDDDDD", "#DDDDDD", "Gray", "Gray") //,"5", "Gray", new Thickness(3, 3, 3, 3))
                .SetVerticalScrollDownButtonColors("White", "Orange", "#DDDDDD", "#0088FF", "White", "0", "Gray", new Thickness(1), "Black", "Orange", "M 0 0 L 3.5 4 L 7 0 Z")
                .SetVerticalScrollThumbColors("#0088FF", "#0088FF", "Gray", "#DDDDDD", "1", "1")

                //HORIZONTAL SCROLLBAR
                .SetHorizontalScrollBarColor(Brushes.WhiteSmoke)
                .SetHorizontalScrollRightButtonColors("#BBB", "Blue", "Red", "Red", "Red", "0", "#FFEE", new Thickness(1), "Black", "Orange", "M 0 0 L 4 4 L 0 8 Z")
                .SetHorizontalPageRightButtonColors("#DDDDDD", "#DDDDDD", "Gray", "Gray") //, "#FFEE", "0", new Thickness(0, 0, 0, 0))
                .SetHorizontalPageLeftButtonColors("#DDDDDD", "Gray", "Gray", "#DDDDDD") // , "#FFEE", "0", new Thickness(0, 0, 0, 0))
                .SetHorizontalScrollLeftButtonColors("#BBB", "Blue", "Red", "Red", "Red", "0", "#FFEE", new Thickness(1), "Black", "Orange", "M 4 0 L 4 8 L 0 4 Z")
                .SetHorizontalScrollThumbColors("#0088FF", "#0088FF", "Gray", "#DDDDDD", "1", "1")
                
                .SetScrollViewerCornerRectangleColor(Brushes.White)
                .EndSettings<TreeView>();

            tListTreeView = new List<Tuple<int, string, string, int>>(); //item1 is the image type, Item2 is the string key, Item3 is the regular counter
            int itrv = 0;
            Enumerable.Range(0,100).ToList().ForEach(x=>{ itrv = populateTupletrv(itrv, x); });

            tListTreeView.ForEach(tup =>
            {       
               
                //leave treeviewargs guid null to signify root treeviewitem
                trv.BeginComposite<TreeView>(tup.Item2)
                    
                        .AddText<TreeView>(0, 0, "VACATION #: " + tup.Item4 + " Lake Michigan")
                        .AddText<TreeView>(1, 0, "Row 1 Col 0")
                        .AddText<TreeView>(1, 1, "Row 1 Col 1")
                        .AddText<TreeView>(2, 0, "Row 2 Col 0")
                        .SetMouseOverColorOnContainer<Grid, TreeView>(Brushes.LightCoral)
                        .EndComposite<TreeView, TreeViewArgs>(new TreeViewArgs(null));

                //add guid to treeviewargs to tell it where to tack onto
                trv.BeginComposite<TreeView>(tup.Item3)
                        .AddText<TreeView>(0, 0, "2nd Item: Boats")
                        .AddText<TreeView>(1, 0, "Row 1 Col 0")
                         .AddText<TreeView>(2, 0, " ")
                        .SetMouseOverColorOnContainer<Grid, TreeView>(Brushes.LightCoral)
                        .EndComposite<TreeView, TreeViewArgs>(new TreeViewArgs(tup.Item2));
            });

            //Append one more to the last key
            char underscore = '_';
            string guidOfLastTreeViewItem = trv.GetChildLookupDictionary<TreeView>().ToList<KeyValuePair<string, object>>().Last<KeyValuePair<string, object>>().Key.Split(underscore)[0].ToString();

            trv.BeginComposite<TreeView>(trvguid5)
                    .AddText<TreeView>(0, 0, "3rd Item: yacht")
                    .AddText<TreeView>(1, 0, "Row 1 Col 0")
                    .SetMouseOverColorOnContainer<Grid, TreeView>(Brushes.LightCoral)
                    .EndComposite<TreeView, TreeViewArgs>(new TreeViewArgs(guidOfLastTreeViewItem));

            trv.BeginComposite<TreeView>(anotherGuid)
                    .AddText<TreeView>(0, 0, "3rd Item: sailboat")
                    .AddText<TreeView>(1, 0, "Row 1 Col 0")
                    .SetMouseOverColorOnContainer<Grid, TreeView>(Brushes.LightCoral)
                    .EndComposite<TreeView, TreeViewArgs>(new TreeViewArgs(guidOfLastTreeViewItem));
           
            #endregion

Last edited Jun 20, 2013 at 4:24 AM by stagathome0069, version 9

Comments

No comments yet.