Wrap Panel Example

WrapPanel.jpg

The WrapPanel may be used to add children to a container from left-to-right, wrapping elements when they reach the end. If desired, you may add the WrapPanel to a ScrollViewer parent to add Scrollbars.

WrapPanel wrap1 = new WrapPanel();

wrap1.Initialize(300, double.NaN, ContainerType.ContentControlPanel, double.NaN, double.NaN, Orientation.Horizontal, FlowDirection.LeftToRight);

wrap1.BeginSettings<WrapPanel>()
          .SetItemBorderSettings<WrapPanel>(double.NaN, double.NaN, Brushes.Gold, new Thickness(2))
          .EndSettings<WrapPanel>();

wrap1.BeginComposite<WrapPanel>(wrapGuid)
         .AddText<WrapPanel>(0, 0, "Hello World 1")
         .EndComposite<WrapPanel, WrapPanelArgs>(null);

wrap1.BeginComposite<WrapPanel>(wrapGuid3)
         .AddText<WrapPanel>(0, 0, "Hello World 3")
         .EndComposite<WrapPanel, WrapPanelArgs>(null);

 wrap1.BeginComposite<WrapPanel>(wrapGuid4)
         .AddText<WrapPanel>(0, 0, "Hello World 4")
         .EndComposite<WrapPanel, WrapPanelArgs>(null);

wrap1.BeginComposite<WrapPanel>(wrapGuid5)
         .AddText<WrapPanel>(0, 0, "Hello World 5")
         .EndComposite<WrapPanel, WrapPanelArgs>(null);

wrap1.BeginComposite<WrapPanel>(wrapGuid6)
          .AddText<WrapPanel>(0, 0, "Hello World 6")
          .EndComposite<WrapPanel, WrapPanelArgs>(null);

wrap1.BeginComposite<WrapPanel>(wrapGuid7)
          .AddText<WrapPanel>(0, 0, "Hello World 7")
          .EndComposite<WrapPanel, WrapPanelArgs>(null);

In the Initialize method, you may vary the Item Height and/or Item Width. For instance, if I change the Initialize code from above to add an Item Width of 300D . . .

wrap1.Initialize(300, double.NaN, ContainerType.DockPanel, double.NaN, 300D, Orientation.Horizontal, FlowDirection.LeftToRight);

Then this is how the Wrap Panel will display:

WrapPanel2.jpg

Last edited Apr 5, 2014 at 9:41 PM by stagathome0069, version 9

Comments

No comments yet.