Show / Hide Table of Contents

Method wpfBuilder.Add(+ 4 overloads)


Overload

Adds an existing element (control etc of any type).

public wpfBuilder Add(FrameworkElement element, WBAdd flags = 0)
Parameters
element  (FrameworkElement)
flags  (WBAdd)
Returns
wpfBuilder
Exceptions
NotSupportedException

The function does not support flag childOfLast for this element type.


Overload(next)

Creates and adds element of type T (control etc of any type).

public wpfBuilder Add<T>(out T variable, object text = null, WBAdd flags = 0) where T : FrameworkElement, new()
Parameters
variable  (T)

Receives element's variable. The function creates element of variable's type. You can use the variable to set element's properties before showing window or/and to get value after. Examples: .Add(out CheckBox c1, "Text"), .Add(out _textBox1). If don't need a variable: .Add(out Label _, "Text") or .Add<Label>("Text").

text  (object)

Text, header or other content. Supported element types (or base types):

  • System.Windows.Controls.TextBox - sets Text property.
  • System.Windows.Controls.ComboBox - sets Text property (see also wpfBuilder.Items).
  • System.Windows.Controls.PasswordBox - sets Password property.
  • System.Windows.Controls.TextBlock - sets Text property (see also wpfBuilder.FormatText and wpfBuilder.formattedText).
  • System.Windows.Controls.HeaderedContentControl, System.Windows.Controls.HeaderedItemsControl - sets Header property (see also wpfBuilder.FormatText and wpfBuilder.formattedText).
  • System.Windows.Controls.ContentControl - sets Content property (can be string, other element, etc) (see also wpfBuilder.FormatText and wpfBuilder.formattedText).
  • System.Windows.Controls.RichTextBox - calls AppendText (see also wpfBuilder.LoadFile).
  • Other element types that have Text property.
flags  (WBAdd)
Returns
wpfBuilder
Exceptions
NotSupportedException

The function does not support non-nulltext or flag ChildOfLast for this element type.

Type Parameters
T

Overload(next)

Creates and adds element of type T (any type). This overload can be used when don't need element's variable.

public wpfBuilder Add<T>(object text = null, WBAdd flags = 0) where T : FrameworkElement, new()
Parameters
text  (object)

Text, header or other content. More info - see other overload.

flags  (WBAdd)
Returns
wpfBuilder
Exceptions
NotSupportedException

The function does not support non-nulltext or flag ChildOfLast for this element type.

Type Parameters
T

Overload(next)

Adds 2 elements: System.Windows.Controls.Label and element of type T (control etc of any type).

public wpfBuilder Add<T>(object label, out T variable, object text = null, WBGridLength? row2 = null) where T : FrameworkElement, new()
Parameters
label  (object)

Label text. Usually string or System.Windows.Controls.TextBlock. Example: new TextBlock() { TextWrapping = TextWrapping.Wrap, Text = "long text" }.

variable  (T)

Variable of second element. More info - see other overload.

text  (object)

Text, header or other content of second element. More info - see other overload.

row2  (WBGridLength?)

If not null, after adding first element calls wpfBuilder.Row with this argument.

Returns
wpfBuilder
Exceptions
NotSupportedException

If the function does not support non-nulltext for this element type.

Type Parameters
T

Remarks

Finally calls wpfBuilder.LabeledBy; it sets System.Windows.Controls.Label.Target, calls System.Windows.Automation.AutomationProperties.SetLabeledBy and applies the bindLabelVisibility option (see wpfBuilder.Options).


Overload(top)

Adds 2 elements: System.Windows.Controls.Label and an existing element (control etc of any type).

public wpfBuilder Add(object label, FrameworkElement element, WBGridLength? row2 = null)
Parameters
label  (object)

Label text. Usually string or System.Windows.Controls.TextBlock. Example: new TextBlock() { TextWrapping = TextWrapping.Wrap, Text = "long text" }.

element  (FrameworkElement)
row2  (WBGridLength?)

If not null, after adding first element calls wpfBuilder.Row with this argument.

Returns
wpfBuilder
Exceptions
NotSupportedException

If the function does not support non-nulltext for this element type.

Remarks

Finally calls wpfBuilder.LabeledBy; it sets System.Windows.Controls.Label.Target, calls System.Windows.Automation.AutomationProperties.SetLabeledBy and applies the bindLabelVisibility option (see wpfBuilder.Options).