Show / Hide Table of Contents

Method wpfBuilder.Items(+ 3 overloads)


Overload

Splits string and ads substrings as items to the last added System.Windows.Controls.ItemsControl (System.Windows.Controls.ComboBox, etc).

public wpfBuilder Items(string items)
Parameters
items  (string)

String like "One|Two|Three".

Returns
wpfBuilder
Exceptions
NotSupportedException

The last added element is not ItemsControl.

Remarks

If it is a non-editable ComboBox, selects the first item. See also wpfBuilder.Select.


Overload(next)

Adds items of any type to the last added System.Windows.Controls.ItemsControl (System.Windows.Controls.ComboBox, etc).

public wpfBuilder Items(params object[] items)
Parameters
items  (object[])

Items of any type (string, WPF element).

Returns
wpfBuilder
Exceptions
NotSupportedException

The last added element is not ItemsControl.

Remarks

If it is a non-editable ComboBox, selects the first item. See also wpfBuilder.Select.


Overload(next)

Adds items as IEnumerable to the last added System.Windows.Controls.ItemsControl (System.Windows.Controls.ComboBox, etc), with "lazy" option.

public wpfBuilder Items(IEnumerable items, bool lazy = false)
Parameters
items  (IEnumerable)

An IEnumerable that contains items (eg array, List) or generates items (eg returned from a yield-return function).

lazy  (bool)

Retrieve items when (if) showing the dropdown part of the ComboBox first time.

Returns
wpfBuilder
Exceptions
NotSupportedException
  • The last added element is not ItemsControl.
  • lazy is true and the last added element is not ComboBox.

Overload(top)

Sets callback function that should add items to the last added System.Windows.Controls.ComboBox later.

public wpfBuilder Items(bool once, Action<ComboBox> onDropDown)
Parameters
once  (bool)

Call the function once. If false, calls on each drop down.

onDropDown  (Action<ComboBox>)

Callback function that should add items. Called before showing the dropdown part of the ComboBox. Don't need to clear old items.

Returns
wpfBuilder
Exceptions
NotSupportedException

The last added element is not ComboBox.