Datasource Problem

Jan 12, 2011 at 3:17 PM

I have implemented ElementFlow Carousel through your Fluid kit !

I am having problem when i Inserted items in StringCollection Class;

Insert(0, "C:/Images/01.jpg");

 

I am not getting image on carousel but the exact string as item .

how to solve it ?

Mar 16, 2011 at 7:39 PM

did you find a solution to your problem ?  I'm having the same issue. I'm runnning VS2010 with 4.0 and cannot get any photos to load in the fluidKit project. please help

Mar 18, 2011 at 10:39 AM

Yeah my problem has been resolved !

Make a Class with name StringCollection and define in xml as:

GameWpf = MyNamespace

StringCollection = Class which contains path to images.

<GameWpf:StringCollection x:Key="DataSource" />

And String colletion class should be inherited with "ObservableCollection<string>", e.g.

using System.Collections.ObjectModel;

namespace GameWpf
{
    public class StringCollection : ObservableCollection<string>
    {
        public StringCollection()
        {

 } } }

<Window x:Class="GameWpf.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="MainWindow" Height="600" Width="800" xmlns:my="clr-namespace:FluidKit.Controls;assembly=FluidKit" xmlns:GameWpf="clr-namespace:GameWpf" xmlns:System="clr-namespace:System;assembly=mscorlib" Loaded="WindowLoaded" KeyDown="ElementFlowKeyDown">
    <Window.Resources>
        <GameWpf:StringCollection x:Key="DataSource" />
    	<DataTemplate x:Key="TestDataTemplate"
                      DataType="{x:Type System:String}">
            <Border x:Name="ElementVisual"
                    Background="White"
                    Padding="5"
                    BorderThickness="5"
                    BorderBrush="LightGray"
                    Grid.Row="0">
                <Image Source="{Binding}"
                       Stretch="Fill" />
            </Border>
        </DataTemplate>
    </Window.Resources>
<Grid>
<my:ElementFlow x:Name="_elementFlow"
            ItemsSource="{DynamicResource DataSource}"
            ItemTemplate="{DynamicResource TestDataTemplate}"
            TiltAngle="45"
            ItemGap="0.2"
            FrontItemGap="1"
            PopoutDistance="1.5"

            SelectedIndex="3" KeyDown="ElementFlowKeyDown" Margin="0,47,-28,277">
            <my:ElementFlow.Layout>
                <my:CoverFlow />
            </my:ElementFlow.Layout>
            <my:ElementFlow.Camera>
                <PerspectiveCamera FieldOfView="45"
                    Position="0,0,6"
                    LookDirection="0,-0,-6" />
            </my:ElementFlow.Camera>
        </my:ElementFlow> 
</Grid>

 C# Codes for MainWindow Class:

using System.Windows;
using System.Windows.Input;
using FluidKit.Controls;

namespace GameWpf
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private StringCollection _dataSource;
        private readonly LayoutBase _layouts = new CoverFlow();

        public MainWindow()
        {
            InitializeComponent();
        }

        private void WindowLoaded(object sender, RoutedEventArgs e)
        {
            _elementFlow.Layout = _layouts;
            //_elementFlow.SelectionChanged += EFSelectedIndexChanged;
            _elementFlow.SelectedIndex = 0;

            _dataSource = FindResource("DataSource") as StringCollection;
            _dataSource.Insert(0, "Images/01.jpg");
            _dataSource.Insert(1, "Images/02.jpg");
            _dataSource.Insert(2, "Images/03.jpg");
            _dataSource.Insert(3, "Images/04.jpg");
            _dataSource.Insert(4, "Images/05.jpg");
            _dataSource.Insert(1, "Images/06.jpg");
            _dataSource.Insert(2, "Images/07.jpg");
            _dataSource.Insert(3, "Images/08.jpg");
            _dataSource.Insert(4, "Images/09.jpg");
            _dataSource.Insert(2, "Images/10.jpg");
            _dataSource.Insert(3, "Images/11.jpg");
            _dataSource.Insert(4, "Images/12.jpg");
        }

        private void ElementFlowKeyDown(object sender, KeyEventArgs e)
        {
            if (e.Key == Key.Left)
            {
                _elementFlow.SelectedIndex -= 1;
            }
            if (e.Key == Key.Right)
            {
                _elementFlow.SelectedIndex += 1;
            }
        }
    }


Thats It !
Its simple than i thought =]