Hey guys, I'm using RadListView with Customized Items and I have some problems that I need help, please check Image attached
this is my custom item class:
class
MensagensCustomListView : SimpleListViewVisualItem
{
LightVisualElement tituloElement;
LightVisualElement descricaoElement;
LightVisualElement textoImageDestaqueElement;
LightVisualElement nossoObterElement;
LightVisualElement fecharElement;
StackLayoutPanel stackLayout;
private
void
Elemento_MouseLeave(
object
sender, EventArgs e)
{
BackColor = Color.Transparent;
BorderColor = Color.FromArgb(221, 221, 221);
fecharElement.Visibility = ElementVisibility.Hidden;
}
private
void
Elemento_MouseEnter(
object
sender, EventArgs e)
{
BackColor = Color.White;
BorderColor = Color.Black;
this
.BorderGradientStyle = GradientStyles.Solid;
var bound = Data.DataBoundItem
as
notificacao_model;
if
(bound.pode_fechar_notificacao)
fecharElement.Visibility = ElementVisibility.Visible;
else
fecharElement.Visibility = ElementVisibility.Hidden;
}
protected
override
void
CreateChildElements()
{
base
.CreateChildElements();
stackLayout =
new
StackLayoutPanel
{
Orientation = System.Windows.Forms.Orientation.Vertical,
ShouldHandleMouseInput =
false
,
NotifyParentOnMouseInput =
true
,
};
textoImageDestaqueElement =
new
LightVisualElement
{
Font =
new
Font(
"Segoe UI"
, 8, FontStyle.Italic, GraphicsUnit.Point),
ForeColor = Color.Gray,
TextAlignment = ContentAlignment.MiddleLeft,
Margin =
new
System.Windows.Forms.Padding(1, 3, 0, 0),
Text =
"Destaque"
,
ShouldHandleMouseInput =
false
,
NotifyParentOnMouseInput =
true
,
Visibility = ElementVisibility.Collapsed,
};
stackLayout.Children.Add(textoImageDestaqueElement);
var stackLayoutHorizontal =
new
StackLayoutPanel
{
ShouldHandleMouseInput =
false
,
NotifyParentOnMouseInput =
true
,
Orientation = Orientation.Horizontal
};
tituloElement =
new
LightVisualElement
{
TextAlignment = System.Drawing.ContentAlignment.MiddleLeft,
TextWrap =
true
,
Margin =
new
System.Windows.Forms.Padding(3, 1, 3, 1),
Font =
new
System.Drawing.Font(
"Segoe UI"
, 9, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point),
ForeColor = System.Drawing.Color.FromArgb(51, 3, 0),
StretchHorizontally =
true
,
ShouldHandleMouseInput =
false
,
NotifyParentOnMouseInput =
true
,
};
stackLayoutHorizontal.Children.Add(tituloElement);
fecharElement =
new
LightVisualElement
{
Font =
new
System.Drawing.Font(
"Arial"
, 10, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point),
ForeColor = System.Drawing.Color.Black,
Text =
"x"
,
StretchHorizontally =
false
,
DisableHTMLRendering =
false
,
BackColor = Color.FromArgb(230, 230, 230),
EnableHighlight =
true
,
HighlightColor = Color.FromArgb(240, 240, 240),
Padding =
new
Padding(5, 2, 5, 2),
DrawFill =
true
,
ToolTipText =
"Fechar Mensagem"
,
NumberOfColors = 1,
Visibility = ElementVisibility.Collapsed,
};
fecharElement.MouseEnter += Elemento_MouseEnter;
fecharElement.MouseLeave += Elemento_MouseLeave;
fecharElement.Click += FecharElement_Click;
stackLayoutHorizontal.Children.Add(fecharElement);
stackLayout.Children.Add(stackLayoutHorizontal);
descricaoElement =
new
LightVisualElement
{
TextAlignment = System.Drawing.ContentAlignment.MiddleLeft,
Margin =
new
System.Windows.Forms.Padding(3, 1, 3, 1),
Font =
new
System.Drawing.Font(
"Segoe UI"
, 8, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point),
ForeColor = System.Drawing.Color.FromArgb(60, 60, 60),
ShouldHandleMouseInput =
false
,
NotifyParentOnMouseInput =
true
,
};
stackLayout.Children.Add(descricaoElement);
nossoObterElement =
new
LightVisualElement
{
Margin =
new
System.Windows.Forms.Padding(190, 5, 3, 0),
Font =
new
System.Drawing.Font(
"Segoe UI"
, 8, FontStyle.Regular, System.Drawing.GraphicsUnit.Point),
ForeColor = Color.FromArgb(153, 153, 153),
Text =
"Mensagem da Obter"
,
ShouldHandleMouseInput =
false
,
NotifyParentOnMouseInput =
true
,
};
stackLayout.Children.Add(nossoObterElement);
Children.Add(stackLayout);
Margin =
new
Padding(6, 0, 0, 0);
Padding =
new
System.Windows.Forms.Padding(1);
BackColor = Color.FromArgb(245, 245, 245);
BorderColor = Color.FromArgb(221, 221, 221);
BorderGradientStyle = GradientStyles.Solid;
DrawBorder =
true
;
DrawFill =
true
;
Shape =
new
RoundRectShape
{
BottomLeftRounded =
true
,
BottomRightRounded =
true
,
TopLeftRounded =
true
,
TopRightRounded =
true
,
Radius = 3
};
this
.MouseEnter += Elemento_MouseEnter;
this
.MouseLeave += Elemento_MouseLeave;
//SetMouseEnterLeave(stackLayout, stackLayoutHorizontal, textoImageDestaqueElement, tituloElement, descricaoElement, nossoObterElement, fecharElement, this);
}
private
void
FecharElement_Click(
object
sender, EventArgs e)
{
var bound = Data.DataBoundItem
as
notificacao_model;
Data.ListView.Items.Remove(Data);
this
.Visibility = ElementVisibility.Collapsed;
if
(bound !=
null
)
{
bound.notificacao_fechada =
true
;
bound.OnFechar();
}
}
protected
override
void
SynchronizeProperties()
{
var bound = Data.DataBoundItem
as
notificacao_model;
if
(bound !=
null
)
{
tituloElement.Text = bound.titulo;
if
(bound.descricao.IsNotNullOrEmpty())
{
descricaoElement.Visibility = ElementVisibility.Visible;
descricaoElement.Text = bound.descricao;
}
else
descricaoElement.Visibility = ElementVisibility.Collapsed;
if
(bound.destaque ==
true
)
{
textoImageDestaqueElement.DrawImage =
true
;
textoImageDestaqueElement.Visibility = ElementVisibility.Visible;
if
(textoImageDestaqueElement.Image ==
null
)
textoImageDestaqueElement.Image =
new
Bitmap(Properties.Resources.favicon.ToBitmap(),
new
Size(16, 16));
}
else
textoImageDestaqueElement.Visibility = ElementVisibility.Collapsed;
if
(bound.mensagem_da_obter)
nossoObterElement.Visibility = ElementVisibility.Visible;
else
nossoObterElement.Visibility = ElementVisibility.Collapsed;
}
}
}