BoldSignEasily embed eSignatures in your .NET applications. Free sandbox with native SDK available.
public class TotalDataTemplateSelector : DataTemplateSelector
{
private readonly DataTemplate _detailTotalDataTemplate;
private readonly DataTemplate _generalTotalDataTemplate;
public TotalDataTemplateSelector(bool expand)
{
_generalTotalDataTemplate = new DataTemplate(typeof(TotalTileViewCell));
_detailTotalDataTemplate = new DataTemplate(typeof(AccordionDetailTotalViewCell));
_detailTotalDataTemplate.SetValue(AccordionDetailTotalViewCell.ExpandedProperty, expand);
}
protected override DataTemplate OnSelectTemplate(object item, BindableObject container)
{
if (item is GeneralTotal)
return _generalTotalDataTemplate;
if (item is DetailTotal)
return _detailTotalDataTemplate;
}
}
The ViewCell itself is just a regular Xamarin.Forms ViewCell with some stacklayout and labels in it. I need the OnBindingContextChanged method because these viewcell are dynamic and I have to take actions depending on the values of the binded object.
public IncomingViewCell()
{
InitializeComponent();
this.View.BindingContextChanged += View_BindingContextChanged;
}
private void View_BindingContextChanged(object sender, EventArgs e)
{
//Modify the data here
var grid = sender as Grid;
} |