<?xml version="1.0" encoding="UTF-8"?><rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>Intersoft Solutions Corporate Blog &#187; iOS</title>
	<atom:link href="http://blog.intersoftsolutions.com/category/ios/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.intersoftsolutions.com</link>
	<description>All about development productivity – ASP.NET, Silverlight, WPF, iOS, Android, Windows Phone, Windows 8</description>
	<lastBuildDate>Sat, 21 Apr 2018 06:57:13 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=4.2.33</generator>
	<item>
		<title>Using Crosslight Location Service in iOS 8</title>
		<link>http://blog.intersoftsolutions.com/2016/08/using-crosslight-location-service-in-ios-8/</link>
		<comments>http://blog.intersoftsolutions.com/2016/08/using-crosslight-location-service-in-ios-8/#comments</comments>
		<pubDate>Mon, 15 Aug 2016 06:05:56 +0000</pubDate>
		<dc:creator><![CDATA[Yudhiy Ariawan]]></dc:creator>
				<category><![CDATA[Crosslight]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Location Service]]></category>

		<guid isPermaLink="false">http://blog.intersoftsolutions.com/?p=8204</guid>
		<description><![CDATA[Using Crosslight Location Service Location service provides a streamlined way to access location API that conforms to each the device’s platform. In order to get the current location of the device, we use following snippet code: This method translate to, get the current location of [...]]]></description>
				<content:encoded><![CDATA[<img width="604" height="270" src="http://blog.intersoftsolutions.com/wp-content/uploads/2016/08/IMG_0221-604x270.png" class="attachment-post-thumbnail wp-post-image" alt="NSLocationWhenInUseUsageDescription" style="float:right; margin:0 0 10px 10px;" /><div id="full-height-container">
<div id="splitter">
<div id="splitter-content">
<div id="main" class="aui-page-panel">
<div id="content" class="page view">
<div class="wiki-content">
<div class="contentLayout2">
<div class="columnLayout two-right-sidebar" data-layout="two-right-sidebar">
<div class="cell normal" data-type="normal">
<div class="innerCell">
<h1>Using Crosslight Location Service</h1>
<p>Location service provides a streamlined way to access location API that conforms to each the device’s platform. In order to get the current location of the device, we use following snippet code:</p><pre class="crayon-plain-tag">this.MobileService.Location.GetCurrentLocation(LocationAccuracy.Best,
    (locationResult) =&gt;
    {
        if (locationResult.Error == null)
		{
		}
        else
		{
		}
    });</pre><p>This method translate to, get the current location of the device, with best accuracy.</p>
</div>
<div class="innerCell">
<div id="full-height-container">
<div id="splitter">
<div id="splitter-content">
<div id="main" class="aui-page-panel">
<div id="content" class="page view">
<div class="wiki-content">
<div class="contentLayout2">
<div class="columnLayout single" data-layout="single">
<div class="cell normal" data-type="normal">
<div class="innerCell">
<h1>Problem: My app doesn&#8217;t returns current location. Why?</h1>
<p>Some of you might found out that the code fails silently. You will get no error or warning, but it will never get a location update. The app will never even ask for permission to use location.</p>
<p>It took me a while until I found that we need to add a key to Info.plist and request authorization from the location manager asking it to start. It&#8217;s an iOS 8 (and later) related issue. The key, <em>NSLocationWhenInUseUsageDescription</em>, is required when you request authorization for location services. If this key is not present, the system ignores your request and prevents your app from using location services.</p>
<h1>Solution: Asking user&#8217;s permission to access their location</h1>
<p>So we&#8217;ll need to add the key to the Info.plist file. It takes a string which is a description of why the app need location services. We can enter a string like &#8220;Location is required to find out where you are&#8221;.</p><pre class="crayon-plain-tag">&lt;?xml version="1.0" encoding="UTF-8"?&gt;
&lt;!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd"&gt;
&lt;plist version="1.0"&gt;
&lt;dict&gt;
	...
	&lt;key&gt;NSLocationWhenInUseUsageDescription&lt;/key&gt;
	&lt;string&gt;Location is required to find out where you are.&lt;/string&gt;
&lt;/dict&gt;
&lt;/plist&gt;</pre><p>Save the changes and re-run the app. Your app will now requesting permission by showing a popup.</p>
<p><a href="http://blog.intersoftsolutions.com/wp-content/uploads/2016/08/IMG_0221.png"><img class="alignnone size-medium wp-image-8205" src="http://blog.intersoftsolutions.com/wp-content/uploads/2016/08/IMG_0221-169x300.png" alt="NSLocationWhenInUseUsageDescription" width="169" height="300" /></a></p>
<p>Hopefully this post may helps developers using location services on iOS 8 (or later). If you have questions or feedback please feel free to submit in the comments section below.</p>
<p>Regards,<br />
Yudi</p>
<p>&nbsp;</p>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.intersoftsolutions.com/2016/08/using-crosslight-location-service-in-ios-8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Adding Header and Footer for iOS TableView and Android ListView</title>
		<link>http://blog.intersoftsolutions.com/2015/11/adding-header-and-footer-for-ios-tableview-and-android-listview/</link>
		<comments>http://blog.intersoftsolutions.com/2015/11/adding-header-and-footer-for-ios-tableview-and-android-listview/#comments</comments>
		<pubDate>Wed, 18 Nov 2015 07:01:08 +0000</pubDate>
		<dc:creator><![CDATA[Nicholas Lie]]></dc:creator>
				<category><![CDATA[Crosslight]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[kb-how-to-article]]></category>
		<category><![CDATA[Products]]></category>
		<category><![CDATA[Tips and Tricks]]></category>
		<category><![CDATA[Android]]></category>
		<category><![CDATA[custom view]]></category>
		<category><![CDATA[footer]]></category>
		<category><![CDATA[header]]></category>
		<category><![CDATA[listview]]></category>
		<category><![CDATA[tableview]]></category>

		<guid isPermaLink="false">http://blog.intersoftsolutions.com/?p=5159</guid>
		<description><![CDATA[Hi guys, I&#8217;m back with another blog post, this time covering how to use the a custom view for header and footer to be used alongside iOS TableView / Android TableView. You&#8217;ll see how you can easily create custom views and use them as headers and footers in [...]]]></description>
				<content:encoded><![CDATA[<img width="604" height="270" src="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Screen-Shot-2015-11-19-at-3.38.19-PM-604x270.png" class="attachment-post-thumbnail wp-post-image" alt="Screen Shot 2015-11-19 at 3.38.19 PM" style="float:right; margin:0 0 10px 10px;" /><p>Hi guys, I&#8217;m back with another blog post, this time covering how to use the a custom view for header and footer to be used alongside iOS TableView / Android TableView. You&#8217;ll see how you can easily create custom views and use them as headers and footers in your Crosslight apps.</p>
<p><img class="alignnone size-large wp-image-5164" src="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Screen-Shot-2015-11-19-at-3.38.19-PM-1024x787.png" alt="Screen Shot 2015-11-19 at 3.38.19 PM" width="604" height="464" /></p>
<p>After this project has completed, you&#8217;ll end up with a custom header and footer in your ListView/TableView. When you click on the Add Item button on the top, new item will be added to the list, and you can see how the header and footer is correctly persisted when the items collection is updated.</p>
<p>To complete this project, there are several steps need to be completed:</p>
<ul>
<li>Preparing the project</li>
<li>Creating custom views for iOS</li>
<li>Preparing the BIndingProvider</li>
<li>Preparing the ViewModel</li>
<li>Modify iOS ViewController and running the project</li>
<li>Creating custom views for Android</li>
<li>Modifying Android ListActivity and running the project</li>
</ul>
<p>Without further ado, let&#8217;s get started.</p>
<h1>Preparing the project</h1>
<p>For this sample, I&#8217;ll keep it nice and simple. This time, I&#8217;ll start from the Navigation template created using Crosslight Project Wizard. I&#8217;ll name this project: <strong>HeaderAndFooter</strong>.</p>
<h1>Creating custom views for iOS</h1>
<p>Let&#8217;s begin by creating a new custom header view for iOS, by right-clicking on the VIews folder in <strong>HeaderAndFooter.iOS/Views</strong> folder and choose <strong>Add</strong>, <strong>New File</strong>.</p>
<p><a href="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Screen-Shot-2015-11-19-at-4.57.27-PM.png"><img class="alignnone size-large wp-image-5166" src="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Screen-Shot-2015-11-19-at-4.57.27-PM-1024x285.png" alt="Screen Shot 2015-11-19 at 4.57.27 PM" width="604" height="168" /></a></p>
<p>Then choose <strong>Crosslight</strong>, <strong>Crosslight iOS View for iPhone</strong>.</p>
<p><a href="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Screen-Shot-2015-11-19-at-4.54.59-PM.png"><img class="alignnone size-large wp-image-5167" src="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Screen-Shot-2015-11-19-at-4.54.59-PM-1024x774.png" alt="Screen Shot 2015-11-19 at 4.54.59 PM" width="604" height="457" /></a></p>
<p>Give it a name of <strong>CustomHeader</strong>. This will generate two files, <em>CustomHeader.xib</em> and <em>CustomHeader.cs</em> for the designer files.</p>
<p>Then open the <em>CustomHeader.xib</em> using Xcode Interface Builder.</p>
<p><a href="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Screen-Shot-2015-11-19-at-4.59.08-PM.png"><img class="alignnone size-large wp-image-5168" src="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Screen-Shot-2015-11-19-at-4.59.08-PM-1024x174.png" alt="Screen Shot 2015-11-19 at 4.59.08 PM" width="604" height="103" /></a></p>
<p>In Xcode Interface Builder, drag a Label and a button.</p>
<p><a href="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Screen-Shot-2015-11-19-at-5.03.12-PM.png"><img class="alignnone size-large wp-image-5169" src="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Screen-Shot-2015-11-19-at-5.03.12-PM-1024x306.png" alt="Screen Shot 2015-11-19 at 5.03.12 PM" width="604" height="180" /></a></p>
<p>Set the label outlet as <strong>TxtHeader </strong>and the button as <strong>BtnHeader</strong>. I won&#8217;t go too much on the layouting details, but you can ensure the followings are set:</p>
<ul>
<li>Set the View size as Freeform, so you can adjust the view size freely.<br />
<a href="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Screen-Shot-2015-11-19-at-5.06.01-PM.png"><img class="alignnone  wp-image-5170" src="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Screen-Shot-2015-11-19-at-5.06.01-PM.png" alt="Screen Shot 2015-11-19 at 5.06.01 PM" width="321" height="89" /></a></li>
<li>Turn off Auto Layout.<br />
<a href="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Screen-Shot-2015-11-19-at-5.06.24-PM.png"><img class="alignnone  wp-image-5171" src="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Screen-Shot-2015-11-19-at-5.06.24-PM.png" alt="Screen Shot 2015-11-19 at 5.06.24 PM" width="318" height="183" /></a></li>
<li>Ensure that the View background is set to <strong>Default</strong> (no fill), this will avoid clipping issues when placed as the header view.<br />
<a href="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Screen-Shot-2015-11-19-at-5.07.15-PM.png"><img class="alignnone  wp-image-5172" src="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Screen-Shot-2015-11-19-at-5.07.15-PM.png" alt="Screen Shot 2015-11-19 at 5.07.15 PM" width="317" height="252" /></a></li>
</ul>
<p>Your custom header is now ready. Let&#8217;s move on to custom footer.</p>
<p>Basically, you&#8217;re going to perform the same tasks as adding a custom header, but the difference is that you&#8217;re going to give it a file name of <strong>CustomFooter</strong>, then provide a label with the outlet of <strong>TxtCopyright</strong>.</p>
<p><a href="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Screen-Shot-2015-11-19-at-9.14.16-PM.png"><img class="alignnone size-large wp-image-5174" src="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Screen-Shot-2015-11-19-at-9.14.16-PM-1024x222.png" alt="Screen Shot 2015-11-19 at 9.14.16 PM" width="604" height="131" /></a></p>
<h1>Preparing the BindingProvider</h1>
<p>Since you&#8217;ve successfully created the custom views, let&#8217;s prepare the <strong>BindingProvider</strong> first to prepare the properties and commands you wish to bind to the View. Open up <strong>NavigationBindingProvider</strong> (I renamed this file to MainBindingProvider to avoid confusion) and add the highlighted lines.</p><pre class="crayon-plain-tag">using Intersoft.Crosslight;

namespace HeaderAndFooter
{
    public class MainBindingProvider : BindingProvider
    {
        #region Constructors

        public MainBindingProvider()
        {
            ItemBindingDescription itemBinding = new ItemBindingDescription()
            {
                DisplayMemberPath = "Title",
                NavigateMemberPath = "Target"
            };

            this.AddBinding("TableView", BindableProperties.ItemsSourceProperty, "Items");
            this.AddBinding("TableView", BindableProperties.ItemTemplateBindingProperty, itemBinding, true);
            this.AddBinding("TableView", BindableProperties.SelectedItemProperty, "SelectedItem", BindingMode.TwoWay);
            
            this.AddBinding("BtnHeader", BindableProperties.TextProperty, "ButtonText");
            this.AddBinding("BtnHeader", BindableProperties.CommandProperty, "AddCommand");
            this.AddBinding("TxtCopyright", BindableProperties.TextProperty, "CopyrightText");
            this.AddBinding("TxtHeader", BindableProperties.TextProperty, "HeaderText");
        }

        #endregion
    }
}</pre><p>From the added lines, notice that we&#8217;re going to do the following:</p>
<ul>
<li>Bind <strong>ButtonText</strong> property in the ViewModel to the <strong>BtnHeader</strong> button.</li>
<li>Bind the ViewModel&#8217;s built-in <strong>AddCommand</strong> to the <strong>BtnHeader</strong> button. This is available in the <em>EditableListViewModel</em> shipped in Crosslight.</li>
<li>Bind the <strong>HeaderText</strong> property in the ViewModel to the <strong>TxtHeader</strong> label.</li>
<li>Bind the <strong>CopyrightText</strong> property in the ViewModel to <strong>TxtCopyright</strong> label. This is for the footer.</li>
</ul>
<p>Since you&#8217;ve prepared everything in the BindingProvider, let&#8217;s modify the ViewModel.</p>
<h1>Modifying the ViewModel</h1>
<p>The  <strong>NavigationViewModel </strong>now looks like the following. It&#8217;s located inside the <strong>HeaderAndFooter.Core/ViewModels</strong> folder.</p><pre class="crayon-plain-tag">using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Linq;
using Intersoft.Crosslight;

namespace HeaderAndFooter.ViewModels
{
    public class NavigationViewModel : SampleListViewModelBase&lt;NavigationItem&gt;
    {
        #region Constructors

        public NavigationViewModel()
        {
            ObservableCollection&lt;NavigationItem&gt; items = new ObservableCollection&lt;NavigationItem&gt;();

            items.Add(new NavigationItem("Simple Page", "About", typeof(SimpleViewModel)));
            items.Add(new NavigationItem("About This App", "About", typeof(AboutNavigationViewModel)));

            this.SourceItems = items;

            this.ButtonText = "Add Item";
            this.CopyrightText = "Copyright © Intersoft Solutions";
        }

        #endregion

        #region Properties

        private string _aboutText { get; set; }
        private string _buttonText { get; set; }
        private string _copyrightText { get; set; }
        private string _headerText { get; set; }

        public string AboutText
        {
            get { return _aboutText; }
            set
            {
                if (_aboutText != value)
                {
                    _aboutText = value;
                    OnPropertyChanged("AboutText");
                }
            }
        }

        public string ButtonText
        {
            get { return _buttonText; }
            set
            {
                if (_buttonText != value)
                {
                    _buttonText = value;
                    OnPropertyChanged("ButtonText");
                }
            }
        }

        public string CopyrightText
        {
            get { return _copyrightText; }
            set
            {
                if (_copyrightText != value)
                {
                    _copyrightText = value;
                    OnPropertyChanged("CopyrightText");
                }
            }
        }

        public string HeaderText
        {
            get
            {
                _headerText = this.Items.Count() + " items.";
                return _headerText;
            }
            set
            {
                if (_headerText != value)
                {
                    _headerText = value;
                    OnPropertyChanged("HeaderText");
                }
            }
        }

        #endregion

        #region Methods

        protected override bool CanExecuteAdd(object parameter)
        {
            return true;
        }

        protected override void ExecuteAdd(object parameter)
        {
            base.ExecuteAdd(parameter);

            NavigationItem newItem = new NavigationItem("Simple Page", "About", typeof(SimpleViewModel));
            var items = this.SourceItems.ToObservable();
            items.Add(newItem);
        }

        protected override void OnCollectionChanged(NotifyCollectionChangedEventArgs e)
        {
            this.OnPropertyChanged("HeaderText");
        }

        #endregion
    }
}</pre><p>Let&#8217;s take a deeper look at this class, starting from the top. In the constructor, we&#8217;ve prepared our <strong>SourceItems</strong> with <strong>ObservableCollection</strong>. We then initialize the <strong>ButtonText</strong> property and the <strong>CopyrightText</strong> property. The <strong>ButtonText</strong> and <strong>CopyrightText</strong> property are all MVVM-ready properties. The <strong>HeaderText</strong> is also an MVVM-ready property, but in the property getter, the text is always updated according to the number of items which exists in the list.</p>
<p>Right after the properties, we then override the built-in <strong>CanExecuteAdd</strong> method to return true so that the AddCommand can be executed, as well as overriding the actions for the <strong>ExecuteAdd </strong>method. Here, we simply add a new <strong>NavigationItem</strong> to the list. Just right after the method, Crosslight has provided an elegant way to perform any additional changes to other properties or any other implementation by overriding the <strong>OnCollectionChanged</strong> method. In the method, we trigger the <strong>OnPropertyChanged</strong> of the <strong>HeaderText</strong>, so that the number of items is always updated in our custom header.</p>
<h1>Modify iOS ViewController and running the project</h1>
<p>Now that you got the Core project covered, let&#8217;s modify the <strong>MainViewController</strong> (located inside <strong>HeaderAndFooter.iOS/ViewControllers</strong>) a bit.</p><pre class="crayon-plain-tag">using CoreGraphics;
using Foundation;
using HeaderAndFooter.ViewModels;
using Intersoft.Crosslight;
using Intersoft.Crosslight.iOS;
using UIKit;

namespace HeaderAndFooter.iOS.ViewControllers
{
    [Register("MainViewController")]
    [ImportBinding(typeof(MainBindingProvider))]
    public class MainViewController : UITableViewController&lt;NavigationViewModel&gt;
    {
        #region Properties

        public override UIViewTemplate HeaderViewTemplate
        {
            get { return new UIViewTemplate(CustomHeader.Nib); }
        }

        public override UIViewTemplate FooterViewTemplate
        {
            get { return new UIViewTemplate(CustomFooter.Nib); }
        }

        public override TableViewInteraction InteractionMode
        {
            get { return TableViewInteraction.Navigation; }
        }

        public override bool ShowGroupHeader
        {
            get { return false; }
        }

        public override UITableViewStyle TableViewStyle
        {
			get { return UITableViewStyle.Plain; }
        }

        #endregion

        #region Methods

        protected override void InitializeView()
        {
            base.InitializeView();

            // set navigation title
            this.NavigationItem.Title = "Crosslight App";
        }

        #endregion
    }
}</pre><p>In the <strong>MainViewController</strong>, we&#8217;ve overridden the <strong>HeaderViewTemplate</strong> as well as <strong>FooterViewTemplate</strong> to return the Nib for each custom header and footer view that we&#8217;ve just defined. We also made things simpler by not showing the group header as wellas ensuring that the used <strong>TableViewStyle</strong> is <strong>Plain</strong>. Run the project. You should get the following result.</p>
<div style="width: 500px; " class="wp-video"><!--[if lt IE 9]><script>document.createElement('video');</script><![endif]-->
<video class="wp-video-shortcode" id="video-5159-1" width="500" height="360" loop="1" autoplay="1" preload="auto" controls="controls"><source type="video/mp4" src="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/iOS-header-footer.mp4?_=1" /><a href="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/iOS-header-footer.mp4">http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/iOS-header-footer.mp4</a></video></div>
<p>If you&#8217;re curious about the separator that exists between the header with the table view, as well as the footer with the table view, it&#8217;s because I&#8217;ve added an additional view in the custom header and footer layout, with the height of 1 unit and giving it a light gray background, to show the boundaries of the custom header and custom footer view. We&#8217;re going to do the same with Android layout later. You&#8217;ve completed the iOS version. Let&#8217;s move on to the Android.</p>
<h1>Creating custom views for Android</h1>
<p>Similar to iOS, you&#8217;ll need to create a custom header view first for Android. To do this, simply right click on the <strong>Resources/layout</strong> folder in the <strong>HeaderAndFooter.Android/Views</strong> folder, then choose <strong>Add</strong>, <strong>New Item</strong>.</p>
<p><a href="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Screen-Shot-2015-11-19-at-9.42.51-PM.png"><img class="alignnone size-large wp-image-5177" src="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Screen-Shot-2015-11-19-at-9.42.51-PM-1024x202.png" alt="Screen Shot 2015-11-19 at 9.42.51 PM" width="604" height="119" /></a></p>
<p>&nbsp;</p>
<p>From the dialog that appears, choose <strong>Android</strong>, <strong>Layout</strong>, and give it a name of <strong>CustomHeader</strong>.</p>
<p><a href="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Screen-Shot-2015-11-19-at-9.43.39-PM.png"><img class="alignnone size-large wp-image-5178" src="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Screen-Shot-2015-11-19-at-9.43.39-PM-1024x794.png" alt="Screen Shot 2015-11-19 at 9.43.39 PM" width="604" height="468" /></a></p>
<p>&nbsp;</p>
<p>And here&#8217;s the contents of the <strong>CustomHeader.axml</strong> file.</p><pre class="crayon-plain-tag">&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    &gt;
    &lt;LinearLayout 
        android:orientation="horizontal"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        &gt;
        &lt;TextView
        	android:id="@+id/TxtHeader"
        	android:layout_width="fill_parent"
        	android:layout_height="30dp"
        	android:textSize="20sp"
        	android:gravity="left"
            android:layout_weight="1"
        /&gt;
        &lt;Button 
            android:id="@+id/BtnHeader"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
        /&gt;
    &lt;/LinearLayout&gt;
    &lt;LinearLayout
            android:layout_width="fill_parent"
            android:layout_height="1px"
            android:background="#f2f2f2"
        /&gt;
&lt;/LinearLayout&gt;</pre><p>This layout simply contains a pretty much similar layout with iOS, that contains a label, a button, and a gray separator at the bottom. Repeat the same procedure for the custom footer layout. Here&#8217;s the contents of the <strong>CustomFooter.axml</strong> file.</p><pre class="crayon-plain-tag">&lt;?xml version="1.0" encoding="utf-8"?&gt;
&lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:orientation="vertical"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    &gt;
    &lt;LinearLayout
        android:layout_width="fill_parent"
        android:layout_height="1px"
        android:background="#f2f2f2"
    /&gt;
    &lt;TextView
    	android:id="@+id/TxtCopyright"
    	android:layout_width="fill_parent"
    	android:layout_height="30dp"
    	android:textSize="12sp"
    	android:gravity="center"
        android:fontFamily="sans-serif-light" 
    /&gt;
&lt;/LinearLayout&gt;</pre><p></p>
<h1></h1>
<h1>Modifying Android ListActivity and running the project</h1>
<p>Since you&#8217;ve prepared the custom views let&#8217;s modify the Android ListActivity to display our custom header and footer. Open up <strong>MainActivity </strong>in the <strong>HeaderAndFooter.Android/Activities</strong> folder and take note of the following changes.</p><pre class="crayon-plain-tag">using Android.App;
using HeaderAndFooter.ViewModels;
using Intersoft.Crosslight;
using Intersoft.Crosslight.Android;

namespace HeaderAndFooter.Android
{
    [Activity(Label = "Crosslight App", Icon = "@drawable/icon")]
    [ImportBinding(typeof(MainBindingProvider))]
    public class MainActivity : ListActivity&lt;NavigationViewModel&gt;
    {
        #region Methods

        protected override void InitializeView()
        {
            base.InitializeView();

            this.RegisterViewIdentifier("TableView", this.ListView);
        }

        #endregion

        #region Properties

        protected override int ContentLayoutId
        {
            get { return Intersoft.Crosslight.Android.Resource.Layout.listgroupsectionlayout; }
        }

        protected override int FooterLayoutId
        {
            get { return Resource.Layout.CustomFooter; }
        }

        protected override int HeaderLayoutId
        {
            get { return Resource.Layout.CustomHeader; }
        }

        public override ListViewInteraction InteractionMode
        {
            get { return ListViewInteraction.Navigation; }
        }

        #endregion
    }
}</pre><p>All you need to do is just override the <strong>FooterLayoutId</strong> as well <strong>HeaderLayoutId</strong> and provide the layout you&#8217;ve just created. If you notice in the template, right in the InitializeView method, we&#8217;re registering the ListView with the TableView identifier at runtime. This is how you would register a view at runtime. For more information in registering view at runtime, check out <a href="http://developer.intersoftsolutions.com/display/crosslight/Getting+Started+with+Crosslight+Android+App#GettingStartedwithCrosslightAndroidApp-RegisteringaViewIdentifieratRuntime">this document</a> in the Developer Center.</p>
<p>You&#8217;re now ready to run the project. You should get the result similar to the following.</p>
<div style="width: 500px; " class="wp-video"><video class="wp-video-shortcode" id="video-5159-2" width="500" height="360" loop="1" autoplay="1" preload="auto" controls="controls"><source type="video/mp4" src="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Android-header-footer.mp4?_=2" /><a href="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Android-header-footer.mp4">http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Android-header-footer.mp4</a></video></div>
<h1>Wrapping Up</h1>
<p>You&#8217;ve seen how easy it is to set up a custom header and footer view to use with iOS TableView and Android ListView. With Crosslight, the custom views are automatically compatible with data binding and Crosslight takes care of the magic, so you can focus on building your app instead of having to worry about wiring behind the scenes. Hopefully this gives you a good insight on how Crosslight accomplishes business scenarios elegantly, without compromising any of the MVVM-design pattern enforced throughout the app.</p>
<p>As always, you can find the source code to this post here: <a href="http://git.intersoftsolutions.com/projects/CT/repos/crosslightheaderandfooter/browse">http://git.intersoftsolutions.com/projects/CT/repos/crosslightheaderandfooter/browse.</a></p>
<p>See you in the next post,<br />
Nicholas Lie</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.intersoftsolutions.com/2015/11/adding-header-and-footer-for-ios-tableview-and-android-listview/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/iOS-header-footer.mp4" length="535560" type="video/mp4" />
<enclosure url="http://blog.intersoftsolutions.com/wp-content/uploads/2015/11/Android-header-footer.mp4" length="319873" type="video/mp4" />
		</item>
		<item>
		<title>Exciting iOS Visual Goodies in Crosslight vNext</title>
		<link>http://blog.intersoftsolutions.com/2015/04/exciting-ios-visual-crosslight-vnext/</link>
		<comments>http://blog.intersoftsolutions.com/2015/04/exciting-ios-visual-crosslight-vnext/#comments</comments>
		<pubDate>Wed, 01 Apr 2015 03:25:33 +0000</pubDate>
		<dc:creator><![CDATA[Jimmy Petrus]]></dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[iOS]]></category>
		<category><![CDATA[Crosslight]]></category>
		<category><![CDATA[UI Components]]></category>

		<guid isPermaLink="false">http://blog.intersoftpt.com/?p=4418</guid>
		<description><![CDATA[Building on rock-solid foundation, the next major iteration of Crosslight will continue to offer new components and features that make cross-platform apps development even easier and more rapidly. There are a number of key areas that we&#8217;re focusing in the upcoming release which include data [...]]]></description>
				<content:encoded><![CDATA[<img width="604" height="270" src="http://blog.intersoftsolutions.com/wp-content/uploads/2015/04/IMG_1648-604x270.png" class="attachment-post-thumbnail wp-post-image" alt="IMG_1648.PNG" style="float:right; margin:0 0 10px 10px;" /><p>Building on rock-solid foundation, the next major iteration of Crosslight will continue to offer new components and features that make cross-platform apps development even easier and more rapidly. There are a number of key areas that we&#8217;re focusing in the upcoming release which include data access, enterprise frameworks, form builders, modern UI components based on latest platforms, as well as new component category that will surely boost your decelopment productivity even further.</p>
<p>In this post, I will give you a sneak preview of the upcoming features particularly for the iOS platform.</p>
<h1 class="">Sliding Parallax Animation</h1>
<p>Since its initial release, Crosslight includes a rich drawer navigation component with sliding animation available for all platforms. The next release will include many visual improvements for the drawer navigation. Specifically for the iOS platform, we&#8217;ll be adding a nice, modern parallax effect alongside with the drawer slide animation. See the example below.</p>
<div style="width: 320px; " class="wp-video"><video class="wp-video-shortcode" id="video-4418-3" width="320" height="590" loop="1" autoplay="1" preload="metadata" controls="controls"><source type="video/mp4" src="http://blog.intersoftpt.com/wp-content/uploads/2015/03/drawer-parallax.mp4?_=3" /><a href="http://blog.intersoftpt.com/wp-content/uploads/2015/03/drawer-parallax.mp4">http://blog.intersoftpt.com/wp-content/uploads/2015/03/drawer-parallax.mp4</a></video></div>
<p>It&#8217;s worth noted that the parallax velocity can be customized according to your desire. It also supports the right-side drawer with consistent experience.</p>
<h1 class="">Stunning Spring Animation</h1>
<p class="">Yep, you read it right! With just a simple property set, you can now quickly add a compelling spring animation to your drawer navigation apps. No wrestling through hundred lines of code and tedious animation works. The built-in spring  animation also handles rotation well when the drawer was opened, then recalculate the new scale size based on the updated orientation — all in buttery-smooth animation.</p>
<div style="width: 320px; " class="wp-video"><video class="wp-video-shortcode" id="video-4418-4" width="320" height="590" loop="1" autoplay="1" preload="metadata" controls="controls"><source type="video/mp4" src="http://blog.intersoftpt.com/wp-content/uploads/2015/03/drawer-spring-animation.mp4?_=4" /><a href="http://blog.intersoftpt.com/wp-content/uploads/2015/03/drawer-spring-animation.mp4">http://blog.intersoftpt.com/wp-content/uploads/2015/03/drawer-spring-animation.mp4</a></video></div>
<h1 class="">New Visual Effect Settings for Table View</h1>
<p class="">In addition to stunning animations, the next release will also include a vast array of new, iOS 8-esque visual effects that can be applied to the table view with just a single property set.</p>
<p class="">Unlike the conventional approach which will require you to create a custom cell template just to apply the vibrancy effect, Crosslight&#8217;s enhanced table view lets you apply a visual effect to the entire table view content by simply specifying the type of the effect you wish to apply. No tedious workaround necessary. So if you&#8217;ve got dozens of table view in existing projects, you&#8217;ll really appreciate this handy time-saving feature.</p>
<p><a href="file:///Users/jimmypetrus/Library/Containers/com.blogo.Blogo/Data/Library/Caches/com.blogo.Blogo/1426929857_full.png" target="_blank"><img class="aligncenter full" title="" src="http://blog.intersoftpt.com/wp-content/uploads/2015/03/1426929891_thumb.png" alt="" align="middle" /></a></p>
<p>Furthermore, you can also easily apply the gorgeous vibrancy effect to the selection background, which beautifully blends together with the new spring layout of drawer navigation.</p>
<p><a href="http://blog.intersoftpt.com/wp-content/uploads/2015/03/1426929978_full.png" target="_blank"><img class="full aligncenter" title="" src="http://blog.intersoftpt.com/wp-content/uploads/2015/03/1426929978_thumb.png" alt="" align="middle" /></a><br />
Alternatively, if you prefer a solid color for the table view content (which still looks great with the parallax background btw), you might want to apply a subtle vibrancy effect to the table separator, just like how Apple did it in some of their interfaces such as in the Notification Center.</p>
<p><a href="http://blog.intersoftpt.com/wp-content/uploads/2015/03/1426929152_full.png" target="_blank"><img class="full aligncenter" title="" src="http://blog.intersoftpt.com/wp-content/uploads/2015/03/1426929152_thumb.png" alt="" align="middle" /></a></p>
<h1 class="">More to Come</h1>
<p>We&#8217;ve got much more exciting stuff in the next major release of Crosslight. Beyond just UI components, the upcoming major release will also deliver the next generation data and enterprise framework which will transform the way you build reliable and scalable business-oriented apps, including support for comprehensive key scenarios on large-scale data sync. Furthermore, data access performance will never be the same again as we&#8217;re coming up with an advanced OData implementation supporting previously-impossible navigational query and aggregate projection — all programmable directly from the client.</p>
<p>Subscribe to our <a title="" href="http://blog.intersoftpt.com" target="_blank">blogs</a>, <a title="" href="https://www.facebook.com/IntersoftSolutions" target="_blank">Facebook</a> and <a title="" href="https://www.twitter.com/intersoftpt" target="_blank">Twitter</a> —stay tuned for our next updates.</p>
<p>Best,<br />
Jimmy</p>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.intersoftsolutions.com/2015/04/exciting-ios-visual-crosslight-vnext/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
<enclosure url="http://blog.intersoftpt.com/wp-content/uploads/2015/03/drawer-parallax.mp4" length="5279693" type="video/mp4" />
<enclosure url="http://blog.intersoftpt.com/wp-content/uploads/2015/03/drawer-spring-animation.mp4" length="5035259" type="video/mp4" />
		</item>
		<item>
		<title>Add a Button with Command Binding in Custom Table Cell</title>
		<link>http://blog.intersoftsolutions.com/2014/10/add-a-button-with-command-binding-in-custom-table-cell/</link>
		<comments>http://blog.intersoftsolutions.com/2014/10/add-a-button-with-command-binding-in-custom-table-cell/#comments</comments>
		<pubDate>Sat, 18 Oct 2014 16:16:05 +0000</pubDate>
		<dc:creator><![CDATA[Yudhiy Ariawan]]></dc:creator>
				<category><![CDATA[iOS]]></category>
		<category><![CDATA[kb-how-to-article]]></category>

		<guid isPermaLink="false">http://blog.intersoftpt.com/2014/10/add-a-button-with-command-binding-in-custom-table-cell/</guid>
		<description><![CDATA[This page discuss how you can customize the appearance and presentation of cell template in a table view for iOS by adding a button with command binding. It is expected that you have successfully displayed a list of data and create custom cell template for [...]]]></description>
				<content:encoded><![CDATA[<img width="604" height="270" src="http://blog.intersoftsolutions.com/wp-content/uploads/2014/10/Screen-Shot-2014-10-10-at-5.17.01-PM-604x270.png" class="attachment-post-thumbnail wp-post-image" alt="Screen Shot 2014-10-10 at 5.17.01 PM" style="float:right; margin:0 0 10px 10px;" /><div>
<div>
<div>
<div data-layout="two-equal">
<div data-type="normal">
<div>
<p>This page discuss how you can customize the appearance and presentation of cell template in a table view for iOS by adding a button with command binding. It is expected that you have successfully displayed a list of data and <a href="http://developer.intersoftpt.com/display/crosslight/Create+Custom+Cell+Template+for+iOS+UITableView">create custom cell template for iOS UITableView</a> before continuing.</p>
<p>Your apps look better when the cell template are presented more intuitively, for instances, adding a button to a TableViewCell. Crosslight has provided techniques that will help you easily customizing the look of your cell template.</p>
<p>In this guide, you will learn how to display a button with command bindings in a custom <em>UITableViewCell</em>. When tapped, the name of the item will be shown in a toast presenter. Follow the simple steps below.</p>
</div>
</div>
<div data-type="normal">
<div>
<div>
<div>
<p><strong>On this page:</strong></p>
<div>
<ul>
<li><a href="http://developer.intersoftpt.com/#AddaButtonwithCommandBindinginCustomTableCell-AddaButtontoCustomCellTemplateView">Add a Button to Custom Cell Template View</a></li>
<li><a href="http://developer.intersoftpt.com/#AddaButtonwithCommandBindinginCustomTableCell-AddCommandtoViewModel">Add Command to ViewModel</a></li>
<li><a href="http://developer.intersoftpt.com/#AddaButtonwithCommandBindinginCustomTableCell-ConfigureBindinginBindingProvider">Configure Binding in BindingProvider</a></li>
<li><a href="http://developer.intersoftpt.com/#AddaButtonwithCommandBindinginCustomTableCell-Samples">Samples</a></li>
</ul>
</div>
</div>
</div>
</div>
</div>
</div>
<div data-layout="single">
<div data-type="normal">
<div>
<h1>Add a Button to Custom Cell Template View</h1>
<p>Let’s start by creating a custom cell template for iOS UITableView and add a Label to the view. Double click the <em>CrosslightiPhoneTableCell1.xib</em> file in Xamarin Studio and it will open up Xcode. In this sample, a Button will be added.</p>
<p><img src="http://blog.intersoftpt.com/wp-content/uploads/2014/10/Screen-Shot-2014-10-10-at-5.17.01-PM.png" alt="" width="500" data-image-src="http://blog.intersoftpt.com/wp-content/uploads/2014/10/Screen-Shot-2014-10-10-at-5.17.01-PM.png" /></p>
</div>
</div>
</div>
<div data-layout="single">
<div data-type="normal">
<div>
<p>&nbsp;</p>
<h1>Add Command to ViewModel</h1>
<p>In the ViewModel, a <a href="http://developer.intersoftpt.com/display/crosslightapi/DelegateCommand+Class">DelegateCommand</a> called TestCommand, is added. This command will be bind to the button so that when user click, it will show a <a href="http://developer.intersoftpt.com/display/crosslight/Toast+Presenter">ToastPresenter</a> with the <em>item.Name</em> information.</p>
<p>Changes in ViewModel is as follow.</p>
<div>
<div>
<pre class="crayon-plain-tag">public DelegateCommand TestCommand { get; set; }

public ItemListViewModel()
{
    // commands
    this.TestCommand = new DelegateCommand(ExecuteTest);
}

private void ExecuteTest(object obj)
{
    Item item = obj as Item;
    if (item != null)
        this.ToastPresenter.Show(item.Name);
}</pre>
</div>
</div>
</div>
</div>
</div>
<div data-layout="single">
<div data-type="normal">
<div>
<p>&nbsp;</p>
<p>&nbsp;</p>
<h1>Configure Binding in BindingProvider</h1>
<p>You will need to configure two binding provider entries to bind the button to the command and the command parameter to be sent, which is the item itself. After adding button in our own custom cell template in the view level, then bind the Button using the <a href="http://developer.intersoftpt.com/display/crosslightapi/BindingProvider+Class" rel="nofollow">BindingProvider</a> class that contains the definition for the view bindings.</p>
<p>The code below shows how to configure the binding for the Button in custom cell template.</p>
<div>
<div>
<pre class="crayon-plain-tag">itemBinding.AddViewModelBinding("TestButton", BindableProperties.CommandProperty, "TestCommand");
itemBinding.AddBinding("TestButton", BindableProperties.CommandParameterProperty, ".");</pre>
</div>
</div>
<p>After saving all the changes, you should see the result similar to the following image when the button is tapped.</p>
<p><img class="alignnone" src="http://blog.intersoftpt.com/wp-content/uploads/2014/10/iOS-Simulator-Screen-Shot-Oct-10-2014-5.16.37-PM.png" alt="" width="300" height="532" border="1" data-image-src="http://blog.intersoftpt.com/wp-content/uploads/2014/10/iOS-Simulator-Screen-Shot-Oct-10-2014-5.16.37-PM.png" /></p>
</div>
</div>
</div>
<div data-layout="single">
<div data-type="normal">
<div>
<p>&nbsp;</p>
<h1>Samples</h1>
<p>The sample code for this article can be downloaded from our Git server: <a href="http://git.intersoftpt.com/projects/CROS-SUPP/repos/add-button-with-commandbinding-in-customtablecell/browse" rel="nofollow">http://git.intersoftpt.com/projects/CROS-SUPP/repos/add-button-with-commandbinding-in-customtablecell/browse</a>.</p>
</div>
</div>
</div>
<div data-layout="single">
<div data-type="normal">
<div>
<p><strong> </strong></p>
<p><strong>Related Topics</strong></p>
<ul>
<li>
<div><span title="Page">Page:</span></div>
<div><a href="http://developer.intersoftpt.com/display/crosslight/Add+a+Button+with+Command+Binding+in+Custom+Table+Cell">Add a Button with Command Binding in Custom Table Cell</a></div>
</li>
<li>
<div><span title="Page">Page:</span></div>
<div><a href="http://developer.intersoftpt.com/display/crosslight/Create+Custom+Cell+Template+for+iOS+UITableView">Create Custom Cell Template for iOS UITableView</a></div>
</li>
<li>
<div><span title="Page">Page:</span></div>
<div><a href="http://developer.intersoftpt.com/display/crosslight/Customizing+Item+Styles">Customizing Item Styles</a></div>
</li>
<li>
<div><span title="Page">Page:</span></div>
<div><a href="http://developer.intersoftpt.com/display/crosslight/Performing+Batch+Update">Performing Batch Update</a></div>
</li>
<li>
<div><span title="Page">Page:</span></div>
<div><a href="http://developer.intersoftpt.com/display/crosslight/Configuring+IISExpress+for+WebAPI+Development">Configuring IISExpress for WebAPI Development</a></div>
</li>
</ul>
<div><a href="http://developer.intersoftpt.com/dosearchsite.action?where=crosslight&amp;queryString=(labelText:kb-how-to-article)%20AND%20(type:page)"><br />
16 related results<br />
</a></div>
</div>
</div>
</div>
</div>
</div>
<div><a href="http://developer.intersoftpt.com/display/crosslight/Add+a+Button+with+Command+Binding+in+Custom+Table+Cell">View Online</a><br />
·<br />
<a href="http://developer.intersoftpt.com/pages/diffpagesbyversion.action?pageId=13992239&amp;revisedVersion=9&amp;originalVersion=8">View Changes Online</a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.intersoftsolutions.com/2014/10/add-a-button-with-command-binding-in-custom-table-cell/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
