<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Nour El Gafy </title>
    <description>The latest articles on DEV Community by Nour El Gafy  (@hackavist).</description>
    <link>https://dev.to/hackavist</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F387030%2F288d29da-e677-4ecd-bfa5-2e03b5fae6e9.jpeg</url>
      <title>DEV Community: Nour El Gafy </title>
      <link>https://dev.to/hackavist</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/hackavist"/>
    <language>en</language>
    <item>
      <title>Xamarin Community Toolkit In Action (Part 1)</title>
      <dc:creator>Nour El Gafy </dc:creator>
      <pubDate>Mon, 11 Jan 2021 22:02:47 +0000</pubDate>
      <link>https://dev.to/hackavist/xamarin-community-toolkit-in-action-part-1-3odj</link>
      <guid>https://dev.to/hackavist/xamarin-community-toolkit-in-action-part-1-3odj</guid>
      <description>&lt;p&gt;The Xamarin Community Toolkit's first stable release is finally out to the public after a very long wait. It marks a special day to me because it is my First contribution to an open source project (but certainly won't be the last) this big. So this series of posts will explain what is the Xamarin Community Toolkit and will show case some of the features in it with code Walkthroughs.&lt;/p&gt;

&lt;h3&gt;
  
  
  What is the Xamarin Community Toolkit ?
&lt;/h3&gt;

&lt;p&gt;For those who don't know about the Xamarin Community toolkit (XCT for short) is the home for some marvelous creations by many talent Xamarin developers, it also houses some of the features that were supposed to be included in Xamarin.Forms 5.0 but the are exploding with potential such as the &lt;code&gt;MediaElement&lt;/code&gt;,the &lt;code&gt;CameraView&lt;/code&gt;, the &lt;code&gt;C# Extensions&lt;/code&gt; and many more so there are now housed in the XCT to further evolve and shine.   &lt;/p&gt;

&lt;h3&gt;
  
  
  How Can the Xamarin Community Toolkit Up My Game ?
&lt;/h3&gt;

&lt;p&gt;The XCT has a very diverse collection of reusable elements that are needed in approximately any app. Such as animations, behaviors, converters, effects, and helpers. It also gathers many of the libraries and packages that are mostly used in every app so it simplifies and demonstrates common developer tasks when building iOS, Android, and Universal Windows Platform (UWP) apps using Xamarin.Forms.&lt;/p&gt;

&lt;h3&gt;
  
  
  Where can one find the Xamarin Community Toolkit ?
&lt;/h3&gt;

&lt;p&gt;As the name implies the XCT is completely open source and it is hosed on Github, You can find it here in the &lt;a href="https://github.com/xamarin/XamarinCommunityToolkit"&gt; Xamarin Community Toolkit Repo&lt;/a&gt;.&lt;br&gt;
As for the documentation you can find it here in this &lt;a href="https://github.com/MicrosoftDocs/xamarin-communitytoolkit"&gt;MicrosoftDocs Repo&lt;/a&gt;;&lt;/p&gt;
&lt;h2&gt;
  
  
  &lt;strong&gt;So Enough with the intro lets dig into it.&lt;/strong&gt;
&lt;/h2&gt;

&lt;p&gt;so for the first touch point I chose the &lt;code&gt;ExpanderView&lt;/code&gt; as it has been a little bit of a hassle to create before.&lt;/p&gt;

&lt;p&gt;The first step would be to create a new Xamarin forms project in out Visual Studio 19 by heading to File&amp;gt;&amp;gt;New&amp;gt;&amp;gt;Project and selecting the Mobile Application (Xamarin.Forms) project.&lt;/p&gt;
&lt;h6&gt;
  
  
  Side Note: &lt;em&gt;We would be using Xamarin.Forms 5 and it only works on VS2019 edition. Learn more &lt;a href="https://docs.microsoft.com/en-us/xamarin/xamarin-forms/release-notes/5.0/5.0.0"&gt;here&lt;/a&gt;.&lt;/em&gt;
&lt;/h6&gt;

&lt;p&gt;Starting with the Blank template we make sure both Android and iOS are selected.&lt;/p&gt;

&lt;p&gt;The first thing we have to do is to update the Xamarin.Forms version to 5.0 and to install the XCT package from the Nuget Package Manager by right clicking the solution and choosing "Manage Nuget Packages for this solution". Search for the "Xamarin Community Toolkit" package and install it. after that update your existing package.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--oIlN317N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fub8wmpue7y701t4d390.png" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--oIlN317N--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/fub8wmpue7y701t4d390.png" alt="PackageUpdate"&gt;&lt;/a&gt;&lt;/p&gt;
&lt;h3&gt;
  
  
  Now we are ready for the code.
&lt;/h3&gt;

&lt;p&gt;We are going to be Building an expandable collection of name tags that expand showing the age and height of people that looks  like this.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--BpcQ8EG5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4hwotccs4jali8m11nke.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--BpcQ8EG5--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/4hwotccs4jali8m11nke.jpg" alt="AllCollaps"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;a href="https://res.cloudinary.com/practicaldev/image/fetch/s--3SApDd-r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/b4foomgafx3ylitlmdua.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://res.cloudinary.com/practicaldev/image/fetch/s--3SApDd-r--/c_limit%2Cf_auto%2Cfl_progressive%2Cq_auto%2Cw_880/https://dev-to-uploads.s3.amazonaws.com/i/b4foomgafx3ylitlmdua.jpg" alt="TwoExpand"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;to get the basics aside i have created a model called &lt;code&gt;NameTagModel&lt;/code&gt; inside my models folder that looks like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    public class NameTagModel
    {
        public string Name { get; set; }
        public int Age { get; set; }
        public int Height { get; set; }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;and another class in my ViewModels folder by the name of &lt;code&gt;NameTagsViewModel&lt;/code&gt; which is only used to provide the view with some dummy data so it looks like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    public class NameTagsViewModel
    {
        public ObservableCollection&amp;lt;NameTagModel&amp;gt; NameTags { get; set; }
        public NameTagsViewModel()
        {
            NameTags = new ObservableCollection&amp;lt;NameTagModel&amp;gt;
            {
                new NameTagModel (){Name="Nour",Age=22,Height=189},
                new NameTagModel (){Name="John",Age=26,Height=184},
                new NameTagModel (){Name="Sam",Age=25,Height=180},
                new NameTagModel (){Name="Betty",Age=23,Height=176},
                new NameTagModel (){Name="Alex",Age=29,Height=175},
            };
        }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;now for the last configuration step we should set the binding context of the view from the code behind of the page in the Views folder &lt;strong&gt;(I know this is not the best Practice it is just for the sake of simplicity for this demo)&lt;/strong&gt;. it should look something like this&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    [XamlCompilation(XamlCompilationOptions.Compile)]
    public partial class NameTagsPage : ContentPage
    {
        NameTagsViewModel NameTagsVM;
        public NameTagsPage()
        {
            InitializeComponent();
            NameTagsVM = new NameTagsViewModel();
            this.BindingContext = NameTagsVM;
        }
    }
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;With that out of the way we can focus on the interesting part.&lt;br&gt;
we are going to create a collection view and bind its &lt;code&gt;ItemsSource&lt;/code&gt; to the NameTags Collection we created earlier&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;    &amp;lt;ContentPage.Content&amp;gt;
        &amp;lt;StackLayout&amp;gt;
            &amp;lt;CollectionView ItemsSource="{Binding NameTags}"&amp;gt;

            &amp;lt;/CollectionView&amp;gt;
        &amp;lt;/StackLayout&amp;gt;
    &amp;lt;/ContentPage.Content&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;p&gt;then we are going to define its &lt;code&gt;ItemTemplate&lt;/code&gt; the &lt;code&gt;Expander&lt;/code&gt; is made up of 2 parts the header and the body (to be shown when expanded) the both can host Views so for the data template we are going to have a &lt;code&gt;Frame&lt;/code&gt; which houses the &lt;code&gt;Expander&lt;/code&gt; and then a &lt;code&gt;StackLayout&lt;/code&gt; with 2 &lt;code&gt;Label&lt;/code&gt;s for the header design.&lt;br&gt;
&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;                    &amp;lt;DataTemplate&amp;gt;
                        &amp;lt;Frame
                            BackgroundColor="#f5f8fe"
                            BorderColor="#7e7e7e"
                            CornerRadius="10"
                            HasShadow="False"&amp;gt;
                            &amp;lt;xct:Expander
                                Margin="10,0"
                                CollapseAnimationEasing="{x:Static Easing.CubicOut}"
                                ExpandAnimationEasing="{x:Static Easing.CubicIn}"&amp;gt;
                                &amp;lt;xct:Expander.Header&amp;gt;
                                    &amp;lt;StackLayout Orientation="Horizontal" Spacing="3"&amp;gt;
                                        &amp;lt;Label
                                            FontSize="Medium"
                                            Text="Name:"
                                            VerticalOptions="CenterAndExpand" /&amp;gt;
                                        &amp;lt;Label
                                            FontAttributes="Bold"
                                            FontSize="Medium"
                                            HorizontalOptions="FillAndExpand"
                                            Text="{Binding Name}" /&amp;gt;
                                    &amp;lt;/StackLayout&amp;gt;
                                &amp;lt;/xct:Expander.Header&amp;gt;
                                &amp;lt;Frame
                                    Padding="10"
                                    BackgroundColor="White"
                                    BorderColor="#7e7e7e"
                                    HasShadow="False"&amp;gt;
                                    &amp;lt;StackLayout&amp;gt;
                                        &amp;lt;StackLayout Orientation="Horizontal" Spacing="5"&amp;gt;
                                            &amp;lt;Label
                                                FontSize="Medium"
                                                Text="Age:"
                                                VerticalOptions="CenterAndExpand" /&amp;gt;
                                            &amp;lt;Label
                                                FontAttributes="Bold"
                                                FontSize="Medium"
                                                HorizontalOptions="FillAndExpand"
                                                Text="{Binding Age}" /&amp;gt;
                                        &amp;lt;/StackLayout&amp;gt;
                                        &amp;lt;StackLayout Orientation="Horizontal" Spacing="5"&amp;gt;
                                            &amp;lt;Label
                                                FontSize="Medium"
                                                Text="Height:"
                                                VerticalOptions="CenterAndExpand" /&amp;gt;
                                            &amp;lt;Label
                                                FontAttributes="Bold"
                                                FontSize="Medium"
                                                HorizontalOptions="FillAndExpand"
                                                Text="{Binding Height}" /&amp;gt;
                                        &amp;lt;/StackLayout&amp;gt;
                                    &amp;lt;/StackLayout&amp;gt;
                                &amp;lt;/Frame&amp;gt;
                            &amp;lt;/xct:Expander&amp;gt;
                        &amp;lt;/Frame&amp;gt;
                    &amp;lt;/DataTemplate&amp;gt;
&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;



&lt;h4&gt;
  
  
  And Here you Go! you have just created an Expanding Card.
&lt;/h4&gt;

&lt;p&gt;This is just a representation for the simplest use of the  &lt;code&gt;Expander&lt;/code&gt;.There are some more things you have to know in order to make more advanced scenarios.&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;There is a bindable property Called &lt;code&gt;IsExpanded&lt;/code&gt; to tell if the &lt;code&gt;Expander&lt;/code&gt; is Expanded.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;There is a bindable Command that takes a bindable command parameter if you want to execute some special logic on Expansion or Shrinking.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;You can stop an Expander from expanding by setting the &lt;code&gt;IsEnabled&lt;/code&gt; property to &lt;code&gt;true&lt;/code&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;Expanders Can be nested into each other.&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h5&gt;
  
  
  You can find the source code &lt;a href="https://github.com/Hackavist/ExpanderSample"&gt;here&lt;/a&gt;.
&lt;/h5&gt;

&lt;h3&gt;
  
  
  To learn more about the &lt;code&gt;Expander&lt;/code&gt; View &lt;a href="https://github.com/MicrosoftDocs/xamarin-communitytoolkit/blob/master/docs/views/expander.md"&gt;click here to visit the documentation&lt;/a&gt;
&lt;/h3&gt;

&lt;p&gt;Thanks for your Time and i hope you enjoyed.&lt;br&gt;
Special Thanks to &lt;a href="https://eg.linkedin.com/in/beshoy-r-mansour"&gt;Beshoy Mansour&lt;/a&gt; for the amazing cover.&lt;br&gt;
See you in part 2 ;)&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>xamarinforms</category>
      <category>android</category>
      <category>ios</category>
    </item>
    <item>
      <title>Xamarin Forms Kick Starter</title>
      <dc:creator>Nour El Gafy </dc:creator>
      <pubDate>Mon, 22 Jun 2020 22:37:38 +0000</pubDate>
      <link>https://dev.to/hackavist/xamarin-forms-kick-starter-2806</link>
      <guid>https://dev.to/hackavist/xamarin-forms-kick-starter-2806</guid>
      <description>&lt;p&gt;Hello Everyone,&lt;/p&gt;

&lt;p&gt;My name is Nour El Gafy, I am software engineering senior college student whose exams were delayed due to the current pandemic situation, which is how the idea of this project came to me.&lt;/p&gt;

&lt;p&gt;Hand in Hand with @OsamaELHosney we started gathering the packages and the snippets that we used in previous projects to create a go to template project in Xamarin forms whenever we wanted to start a new one &lt;/p&gt;

&lt;p&gt;that is how &lt;a href="https://hackavist.github.io/XamarinKickStartTemplate/"&gt;Xamarin Kickstarter Template&lt;/a&gt; came to life.&lt;/p&gt;

&lt;p&gt;I will be writing several Posts explaining some of the cool features in this template. starting with the &lt;em&gt;LocalNotificationService&lt;/em&gt;&lt;/p&gt;

&lt;p&gt;Your feedback and contribution to the repo are highly appreciated.&lt;/p&gt;

&lt;p&gt;Stay Safe and Have a good one&lt;/p&gt;

</description>
      <category>csharp</category>
      <category>xamarin</category>
      <category>ios</category>
      <category>android</category>
    </item>
  </channel>
</rss>
