Example #1
0
        protected virtual string OnSelectTemplateKeyCore(object dataContext, UIElement owner)
        {
            if (m_args is null)
            {
                m_args = new SelectTemplateEventArgs();
            }

            var args = m_args;

            args.TemplateKey = null;
            args.DataContext = dataContext;
            args.Owner       = owner;

            SelectTemplateKey?.Invoke(this, args);

            var templateKey = args.TemplateKey;

            if (string.IsNullOrEmpty(templateKey))
            {
                throw new InvalidOperationException("Please provide a valid template identifier in the handler for the SelectTemplateKey event.");
            }

            return(templateKey);
        }
 private void OnSelectTemplateKeyPhased(RecyclingElementFactory sender, SelectTemplateEventArgs args)
 {
     args.TemplateKey = args.DataContext is Recipe ? "RepeaterItemTemplatePhased" : "RepeaterGroupTemplatePhased";
 }
Example #3
0
 private void OnSelectTemplateKey(RecyclingElementFactory sender, SelectTemplateEventArgs args)
 {
     args.TemplateKey = (int.Parse(args.DataContext.ToString()) % 2 == 0) ? "even" : "odd";
 }
Example #4
0
 private void GridViewGenerator_SelectTemplateKey(RecyclingViewGenerator sender, Microsoft.UI.Xaml.Controls.SelectTemplateEventArgs args)
 {
     args.TemplateKey = ((SampleData)args.DataContext).Value >= 200 ? nameof(this.EllipseItem) : nameof(this.RectangleItem);
 }