コード例 #1
0
 public void Initalize(BindingContext context)
 {
     _context = context;
     foreach (Element el in _context.GetElementsForTag("animals"))
     {
         var chkEl = el as CheckboxElement;
         if (chkEl != null)
         {
             chkEl.Tapped += UpdateCatsAndDogs;
         }
     }
 }
コード例 #2
0
        public void UpdateCatsAndDogs()
        {
            int dogs  = _context.GetElementsForTag("dogs").Where(el => ((CheckboxElement)el).Value).Count();
            int cats  = _context.GetElementsForTag("cats").Where(el => ((CheckboxElement)el).Value).Count();
            int small = _context.GetElementsForTag("small").Where(el => ((CheckboxElement)el).Value).Count();
            int big   = _context.GetElementsForTag("big").Where(el => ((CheckboxElement)el).Value).Count();

            var kindsEl = _context.GetElementsForTag("kinds").FirstOrDefault() as EntryElement;
            var sizesEl = _context.GetElementsForTag("sizes").FirstOrDefault() as EntryElement;

            kindsEl.Value = string.Format("{0} dogs, {1} cats", dogs, cats);
            sizesEl.Value = string.Format("{0} small, {1} big", small, big);
        }