Posts

Events, inheritance and polymorphism

بعد ما تخلص قراية هتعرف أكتر عن: Inheritance and overriding base class How to declare your own List class (with Add and Clear functions) Events and delegates Fire specific events when you add to/ remove from list (triggers): writing database logger. المطلوب: لما يحصل تغيير في List سواء بالإضافة أو الحذف أو التعديل يتسجل نوع التغيير اللي حصل ووقته في ملف (للتبسيط هيكون string). عشان تقدر تتحكم أكتر في العمليات اللي بتحصل في ال List هنكتب كلاس يـ inherit من كلاس ArrayList (الأفضل إنك تحاول قدر الإمكان تبعد عن ال ArrayList عشان مش Type safe، وتـ   Implement ICollection<T>  بس هنستخدمها للتبسيط، المبدأ واحد في الحالتين) نبدأ نـ Inherit من ArrayList ونـ override ال methods اللي محتاجينها (هنشتغل على Add و Clear) عشان تـ fire event فدا معناه تهندله (handle) لما يحصل حدث معين، بتهندله في ميثود؛ الميثود دي شكلها ثابت في أي إيفنت، وهي إنها مش بترجع قيمة وبتاخد اتنين باراميترز، أول باراميتر الأوبجكت اللي أطلق الإيفنت، في المثال بتاعنا هو...

Creating RadioButtonsGroup control in Xamarin.Forms

Image
The RadioButton control is one of the most used controls in almost any application, however Xamarin Forms does not ship with one, so what do you do? Yes, create it; it’s a good opportunity to have some fun creating a missing control. Let’s address the problem in detail. What do you need? I need a RadioButtonsGroup control not just a single control; that can render n th of radio buttons equal to the items bound to it from its ItemsSource property. We also need to know which item from the ItemsSource collection has been selected by data binding, for that, the control will have SelectedItem Property for the whole selected object, but you may be interested in only one property from that object like ID, so we’ll implement SelectedValue as well, and also SelectedIndex . And Orientation property for the Horizontal & Vertical orientation . When you bind the control to a collection of items, the control need to know what property is used for the displayed text and what pro...