How do I get rid of the Expand / Collapse on Each card? (See Capture1)
Also, it might be related, but I would like the photo to expand to fill to the top and side edges in the card, as in the Telerik UI for WinForms demo application. (See Capture2).
I copied this Demo code exactly, even editing the form1.Designer.vb, so they should look the same, but I still get variations between the two. In designer editing properties directly, it will not hold several properties, changing them to what the control thinks they should be. This is especially true for trying to set the size and location of the CardViewItems.
Please advise.
Thanks,
7 Answers, 1 is accepted
Since we are using UI Virtualization you can access the items in the CardViewItemFormatting event. The following snippet shows how you can hide the group header and set the padding:
private
void
RadCardView1_CardViewItemFormatting(
object
sender, Telerik.WinControls.UI.CardViewItemFormattingEventArgs e)
{
var visualItem = e.VisualItem
as
CardListViewVisualItem;
visualItem.Padding =
new
Padding(0);
var groupItem = visualItem.CardContainer.Items[0]
as
CardViewGroupItem;
groupItem.Padding =
new
Padding(0);
groupItem.HeaderElement.Visibility = Telerik.WinControls.ElementVisibility.Collapsed;
CardViewItem item = e.Item
as
CardViewItem;
if
(item !=
null
&& item.FieldName ==
"MyImage"
)
{
item.DrawText =
false
;
item.EditorItem.ImageLayout = ImageLayout.Stretch;
}
}
I hope this will be useful. Let me know if you have additional questions.
Regards,
Dimitar
Progress Telerik
Excellent!
Thanks for the prompt response.
Hello,
how I read data from selected cardview item ? SelectedItemChanged or SelectedIndexChanged ? Please example.
Best regards,
HB
Both events are suitable, here is how you can get the data from the selected item:
private
void
RadCardView1_SelectedItemChanged(
object
sender, EventArgs e)
{
var data = radCardView1.SelectedItem.DataBoundItem
as
DataModel;
Console.WriteLine(data.Name);
}
I hope this helps. Should you have any other questions do not hesitate to ask.
Dimitar
Progress Telerik
Hello,
Thanks for your reply. I did not work with DataModel, but CardView was filled dynamically through the loop. I worked on an example from the attachment.
this.radCardView1.Items.Add("a","b","c","d");
Best regards,
HB
This will work if the control is bound to a data source. In your case you can directly access the data like this:
private
void
RadCardView1_SelectedIndexChanged(
object
sender, EventArgs e)
{
if
(radCardView1.SelectedItem ==
null
)
{
return
;
}
var data = radCardView1.SelectedItem[
"Column 1"
];
Console.WriteLine(data);
}
I hope this will be useful. Let me know if you have additional questions.
Regards,
Dimitar
Progress Telerik
Excellent!
Thanks a lot.
Best regards,
HB