I'm trying to create a ListView with custom items, as shown in the attached image. The lower textbox can be of varying height due to containing more or less text lines.
I have tried a horizontal StackLayout with three text boxes (RadTextBoxElement). I then use a vertical StackLayout containing the first stacklayout plus a fourth textbox. I have used the sample in the docs as a basis.
I have the listview type as ListViewType.ListView. I also have AllowArbitraryItemHeight = true.
I can't get the lower textbox to display larger than a single line, despite containing multiple text lines.
The custom visual item class is below. In this version I'm actually using a RadLabelElement for the lower item instead of a textbox as it does show relatively ok, but has drawbacks like not being able to select & copy text from it.
using
System;
using
System.Drawing;
using
System.Windows.Forms;
using
Telerik.WinControls.Layouts;
using
Telerik.WinControls.UI;
namespace
UCStudio.UI
{
public
class
RuleVisualItem : SimpleListViewVisualItem
{
private
RadTextBoxElement _idElement;
private
RadTextBoxElement _sequenceElement;
private
RadTextBoxElement _nameElement;
private
RadLabelElement _ruleTextElement;
private
LightVisualElement _contentElement;
private
StackLayoutPanel _vStackLayout;
private
StackLayoutPanel _stackLayout;
protected
override
void
CreateChildElements()
{
base
.CreateChildElements();
_stackLayout =
new
StackLayoutPanel
{
Orientation = Orientation.Horizontal,
//AutoSize = true,
EqualChildrenWidth =
true
,
ShouldHandleMouseInput =
false
,
NotifyParentOnMouseInput =
true
};
_vStackLayout =
new
StackLayoutPanel
{
Orientation = Orientation.Vertical,
ShouldHandleMouseInput =
false
,
NotifyParentOnMouseInput =
true
};
_contentElement =
new
LightVisualElement
{
StretchHorizontally =
true
,
MinSize =
new
Size(120, 0),
ShouldHandleMouseInput =
false
,
NotifyParentOnMouseInput =
true
};
_idElement =
new
RadTextBoxElement {Text =
""
};
_idElement.TextBoxItem.ReadOnly =
true
;
_stackLayout.Children.Add( _idElement);
_sequenceElement =
new
RadTextBoxElement {Text =
""
};
_sequenceElement.TextBoxItem.ReadOnly =
true
;
_stackLayout.Children.Add( _sequenceElement);
_nameElement =
new
RadTextBoxElement {Text =
""
};
_nameElement.TextBoxItem.ReadOnly =
true
;
_stackLayout.Children.Add( _nameElement);
_stackLayout.Children.Add( _contentElement);
_ruleTextElement =
new
RadLabelElement
{
Text =
""
,
ShouldHandleMouseInput =
false
,
NotifyParentOnMouseInput =
true
};
_vStackLayout.Children.Add( _stackLayout);
_vStackLayout.Children.Add( _ruleTextElement);
Children.Add( _vStackLayout);
}
protected
override
void
SynchronizeProperties()
{
base
.SynchronizeProperties();
Text =
""
;
_contentElement.Text =
""
;
_idElement.Text = Convert.ToString( Data[
"RuleItemId"
]);
_sequenceElement.Text = Convert.ToString( Data[
"Sequence"
]);
_nameElement.Text = Convert.ToString( Data[
"Name"
]);
_ruleTextElement.Text = Convert.ToString( Data[
"RuleItemText"
]);
}
protected
override
Type ThemeEffectiveType =>
typeof
(SimpleListViewVisualItem);
}
}
Also I don't know why I need to use the LightVisualElement _contentElement; If I remove this the textboxes in the horizontal stacklayout show as minimal size.
Another thing is I need the third textbox in the top group to be of varying size, i.e. to fit itself to its content but it isn't, because of EqualChildrenWidth = true (which I need or the textboxes show as tiny, again).
I'm struggling to find the correct combination of techniques to achieve the above. Any help appreciated.