The Items in FlowItemsControl2D not showing up

Apr 18, 2012 at 7:09 AM


   First of all I must congratulate you for the nice control that you created. I am trying to use your control in one of my project. I did as per my understanding all the things that is there in your sample project. But unfortunately the items in the control is not showing up. Below is my xaml code.


<UserControl x:Class="XCloud.DTE.Views.GalleryViews.ServiceGalleryView"
    d:DesignHeight="300" d:DesignWidth="400" u:AttachedPropeties.Title="Service Gallery">

        <Style TargetType="flow:FlowItem3D" x:Key="empty3D">
            <Setter Property="Template">
                    <ControlTemplate TargetType="flow:FlowItem3D">
                        <ContentPresenter />

        <Style TargetType="flow:FlowItem2D" x:Key="empty2D">
            <Setter Property="Template">
                    <ControlTemplate TargetType="flow:FlowItem2D">
                        <ContentPresenter />

        <DataTemplate x:Key="itemTemplate">
            <flow:InFlowContentControl Content="{Binding ColorName}" Background="{Binding Brush}" HeadingBackground="{Binding HeaderBrush}" Width="150" Height="150" />


    <Grid Background="#60FFFFFF">
            <RowDefinition Height="*"/>
            <RowDefinition Height="0.3*"/>
            <ColumnDefinition Width="*"/>
        <flow:FlowItemsControl2D ItemsSource="{Binding Items}" ItemTemplate="{StaticResource itemTemplate}" ItemContainerStyle="{StaticResource empty2D}" />

And below is my code for the view model

using XCloud.Client.SilverlightFramework.ViewModel;
using XCloud.Model;
using System.Windows.Media;
using System.Collections.Generic;
using System.Linq;

namespace XCloud.DTE.ViewModels
    public class ServiceGalleryViewModel : BaseViewModel
        protected override void ActivateView(string viewName, System.Collections.Generic.IDictionary<string, object> viewParameters)
            var templates = new ServiceTemplateList();
            templates.Execute((s,f) =>
                    this.Templates = templates;


        private ServiceTemplateList _templates;

        public ServiceTemplateList Templates
            get { return this._templates; }
                this._templates = value;

         public class Item
            public string ColorName { get; set; }
            public Brush Brush { get; set; }
            public Brush HeaderBrush { get; set; }

        private readonly List<Item> _items = new List<Item>();
        public List<Item> Items { get { return _items; } }

        public ServiceGalleryViewModel()
            foreach (var property in typeof(Colors).GetProperties(System.Reflection.BindingFlags.Static | System.Reflection.BindingFlags.Public).Where(p => p.PropertyType == typeof(Color) && p.Name != "Transparent"))
                var name = property.Name;
                var color = (Color) property.GetValue(null, null);
                var bg = new SolidColorBrush(color);
                var headerBrush = new LinearGradientBrush(new GradientStopCollection
                    new GradientStop{Offset=0, Color = Color.FromArgb(255,(byte) (color.R *0.5),(byte) (color.G *0.5),(byte) (color.B *0.5))},
                    new GradientStop{Offset=1, Color = Color.FromArgb(20,(byte) (color.R *0.5),(byte) (color.G *0.5),(byte) (color.B *0.5))}
                }, 0);

                _items.Add(new Item { Brush = bg, ColorName = name, HeaderBrush = headerBrush });



Now just to let you know here the framework takes care of putting the viewmodel to the view. That is the framework first. Creates 
the view model and then assign it to the datacontext of the view and then display the view. Please do let me know if it helps you to 
understand my problem and if you can help me fix it. 


Apr 18, 2012 at 7:53 AM

Ok here is some more info I though I should add which will help you find the issue. I did found that it is properly setting 14 items in the control and data context is getting properly assigned. So logically it is getting the data source and itemssource. But nothing is showing up.. :(