DialogBox (Border) Example

To see examples for creating DialogBoxes using Border as the foundational control, look here: Dialogs.

In WPF-CPS, the Border is used as a general-purpose, root container for all Composites. As such, it may be similar in usage to the DIV tag in HTML. It may be similar to a ContentControl (in that it may hold a single child) except that it has a potentially visible border with a thickness and a color (different from the background color.)

Below is an example of creating a simple, flat Button by using a Border with a MouseOverColor:

Border borderButton = new Border();
borderButton.MaxHeight = 50;
borderButton.Initialize(double.NaN, double.NaN, ContainerType.HorizontalPanel, Brushes.Indigo, new Thickness(2), Brushes.PowderBlue, new CornerRadius(10), new Thickness(0), new Thickness(1));

borderButton.BeginSettings<Border>()
                .SetTextPadding<Border>(0, 0, new Thickness(4))
                .SubscribeMouseSingleClickOnBorder<Border>((o, ev) =>
                {   
// . . .  do something on mouse single click . . .
                })
                .EndSettings<Border>();

borderButton.SetMouseOverColorOnBorder(Brushes.Orange);

Border borderOfTheComposite = borderButton.BeginComposite()
                .AddText<Border>(0, 0, "  Do It  ")
                .EndComposite<Border, BorderArgs>(null);

Note that BeginComposite . . . EndComposite always returns a Border regardless of the type of Composite. (In the example above, this may be a Border within a Border!)

You can do a lot with this Border, such as getting or removing children from within the composite. However, one of the most important methods available on Border is GetKey() which will return the unique key (default is a guid) of the Composite.

Last edited Apr 9, 2014 at 4:37 AM by stagathome0069, version 16

Comments

No comments yet.