﻿<?xml version="1.0" encoding="utf-8"?><rss 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:media="http://search.yahoo.com/mrss/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0"><channel><title>Intersoft Community - Lounge - How to bind color to GridView cell background?</title><link>http://www.intersoftsolutions.com/Community/Lounge/How-to-bind-color-to-GridView-cell-background/</link><description /><generator>http://www.intersoftsolutions.com</generator><language>en</language><copyright>Copyright 2002 - 2015 Intersoft Solutions Corp. All rights reserved.</copyright><ttl>60</ttl><item><title>How to bind color to GridView cell background?</title><link>http://www.intersoftsolutions.com/Community/Lounge/How-to-bind-color-to-GridView-cell-background/</link><pubDate>Tue, 05 May 2015 01:45:40 GMT</pubDate><dc:creator>Arief</dc:creator><category>binding</category><category>android</category><category>GridView</category><category>Crosslight</category><category>bindingprovider</category><description>&lt;p&gt;Glad it work!,&lt;br&gt;&lt;br&gt;Should you need further assistance or run into any problems regarding our controls, feel free to post it into our forum. We would be happy to assist you again!&lt;/p&gt;</description></item><item><title>How to bind color to GridView cell background?</title><link>http://www.intersoftsolutions.com/Community/Lounge/How-to-bind-color-to-GridView-cell-background/</link><pubDate>Mon, 04 May 2015 07:55:50 GMT</pubDate><dc:creator>cristobal@sbsoftware.es</dc:creator><category>binding</category><category>android</category><category>GridView</category><category>Crosslight</category><category>bindingprovider</category><description>&lt;p&gt;Thank you very much!! This method is OK&lt;/p&gt;</description></item><item><title>How to bind color to GridView cell background?</title><link>http://www.intersoftsolutions.com/Community/Lounge/How-to-bind-color-to-GridView-cell-background/</link><pubDate>Mon, 30 Mar 2015 10:15:30 GMT</pubDate><dc:creator>Arief</dc:creator><category>binding</category><category>android</category><category>GridView</category><category>Crosslight</category><category>bindingprovider</category><description>&lt;p&gt;Hi Cristobal,&lt;br&gt;&lt;br&gt;&lt;b&gt;First of all,&lt;/b&gt; you must create a Custom GridViewCell, because our GridViewCell doesn't have id that can be used to bind with the cell background, so you must make a Custom one including the id inside the layout.&lt;br&gt;&lt;/p&gt;&lt;p&gt;Please remember that you only need this code inside your view model to access data from model and repository or local List&amp;lt;&amp;gt; :&amp;nbsp;&lt;span style="font-family: 'Courier New', Tahoma; font-size: 9pt; background-color: rgb(255, 252, 225);"&gt;this.SourceItems = this.Repository.GetAll().ToObservable();&lt;br&gt;&lt;br&gt;&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Next t&lt;span style="font-size: 10pt;"&gt;o connect with the background color, there are however there are&lt;b&gt; two method&lt;/b&gt; to access the value from the data&lt;/span&gt;&lt;/p&gt;&lt;p&gt;&lt;b&gt;First Method &lt;/b&gt;is you can manipulate your model by adding this:&lt;br&gt;&lt;/p&gt;&lt;pre&gt; public StyleAttributes ColorStyle        {            get            {                return new StyleAttributes(){
                    BackgroundColor=(this.Color == Red)?Color.FromArgb(0xff,0xff,0x00,0x00):&lt;span style="font-size: 9pt;"&gt;Color.FromArgb(0xff,0xff,0xff,0xff)&lt;/span&gt;&lt;br&gt;
                };
            }
        }&lt;/pre&gt;&lt;p&gt;Note you can change Color.FromArgb with our premade color using for example: Colors.Red or Colors.Transparent, also remember to add 0x before hex code because it only accept byte&lt;br&gt;&lt;br&gt;Then&amp;nbsp;inside your binding provider you can add:&lt;br&gt;&lt;/p&gt;&lt;pre&gt;itemBinding.AddBinding("YourCellBackgroundID", BindableProperties.StyleAttributesProperty, new BindingDescription("ColorStyle"));&lt;/pre&gt;&lt;p&gt;This could be done because when you can call List/Grid type you can also access your model from there&lt;br&gt;&lt;br&gt;&lt;b&gt;Another method&lt;/b&gt; you can use is converter:&lt;br&gt;&lt;br&gt;Add this inside your binding provider:&lt;/p&gt;&lt;pre&gt;itemBinding.AddBinding("&lt;span style="font-size: 9pt;"&gt;YourCellBackgroundID&lt;/span&gt;&lt;span style="font-size: 9pt;"&gt;", BindableProperties.StyleAttributesProperty, new BindingDescription("Color")&lt;/span&gt;{ Converter = new ColorConverter()}&lt;span style="font-size: 9pt;"&gt;);&lt;/span&gt;&lt;/pre&gt;&lt;p&gt;&lt;br&gt;Make new file named ColorConverter with class ColorConverter and insert this inside:&lt;br&gt;&lt;/p&gt;&lt;pre&gt;	public class &lt;span style="font-size: 9pt;"&gt;ColorConverter&lt;/span&gt;&lt;span style="font-size: 9pt;"&gt;: IValueConverter&lt;/span&gt;&lt;br&gt;	{
		#region IValueConverter implementation

		public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
		{
			if (value is String)
			{
				int CatColor = (String)value;

                if (CatColor == "Red")
                {
                    StyleAttributes style = new StyleAttributes();

                    style.BackgroundColor = Colors.Red;
                    return style;
                }
                else 
                {
                    StyleAttributes style = new StyleAttributes();

                    style.BackgroundColor = Colors.White;
                    return style;
                }
			}

			return null;
		}

		public object ConvertBack(object value, Type targetType, object parameter, CultureInfo culture)
		{
			throw new System.NotImplementedException();
		}

		#endregion
	}&lt;/pre&gt;&lt;p&gt;Connect your binding provider with this converter&lt;br&gt;&lt;br&gt;&lt;b&gt;So in conclusion&lt;/b&gt;, i think the second method is more cleaner and doesn't manipulate the model too much... The only file you actually need to changes is just the Layout and Binding Provider (also model or converter)&lt;br&gt;&lt;br&gt;You can also see this kind of implementation in our samples:&amp;nbsp;&lt;a href="http://git.intersoftpt.com/projects/CROS/repos/samples/browse/MyInventory" target="_blank"&gt;http://git.intersoftpt.com/projects/CROS/repos/samples/browse/MyInventory&lt;/a&gt;&lt;/p&gt;&lt;p&gt;&lt;br&gt;Hope that helps :)&lt;br&gt;&lt;br&gt;Best Regards,&lt;br&gt;Arief&lt;/p&gt;</description></item><item><title>How to bind color to GridView cell background?</title><link>http://www.intersoftsolutions.com/Community/Lounge/How-to-bind-color-to-GridView-cell-background/</link><pubDate>Mon, 23 Mar 2015 09:17:10 GMT</pubDate><dc:creator>cristobal@sbsoftware.es</dc:creator><category>binding</category><category>android</category><category>GridView</category><category>Crosslight</category><category>bindingprovider</category><description>&lt;p&gt;Dear crosslight developer.&lt;/p&gt;&lt;p&gt;I'm writting to you because I want to bind the background color in a gridview cell, using hexadecimal color with is saving in a property model's.&lt;/p&gt;&lt;p&gt;My model have a Color property and my ViewModel is ListViewModel&amp;lt;Model&amp;gt;, and it draw a gridview. Each one of those cells should bind a model color property with a cell background color&lt;span style="font-size: 10pt;"&gt;.&lt;/span&gt;&lt;/p&gt;&lt;p&gt;Could you tell me if I need a custom bindingprovider? How can I do it?&lt;/p&gt;&lt;p&gt;Thank you very much.&lt;/p&gt;</description></item></channel></rss>