SelectedIndex dont move

Aug 23, 2011 at 7:47 PM
Edited Aug 23, 2011 at 7:49 PM

hi im starting to use Fluidkit when i try to change the selected Index... it change or at least it seems to change on the output... but in the ElementFlow nothing happen here's my XAML 

 

<Window x:Class="Cookbook.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:sys="clr-namespace:System;assembly=mscorlib"
         xmlns:controls="clr-namespace:FluidKit.Controls;assembly=FluidKit"
        xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
        xmlns:Samples="clr-namespace:FluidKit.Samples;assembly=FluidKit.Samples"
        xmlns:Value="clr-namespace:System;assembly=mscorlib"
        Title="CookBook-Test Version" Height="350" Width="525" WindowState="Maximized" >
    <Window.Resources>
        <Samples:StringCollection x:Key="DataSource" />
        <DataTemplate x:Key="TestDataTemplate"
                      DataType="{x:Type sys:String}">
            <Border x:Name="ElementVisual"
                    Background="White"
                    Padding="5"
                    BorderThickness="5"
                    BorderBrush="LightGray"
                    Grid.Row="0">
                <Image Source="{Binding}"
                       Stretch="Fill" />
            </Border>
        </DataTemplate>

        <DataTemplate x:Key="TestDataTemplate_Reflection">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="0.5*" />
                    <RowDefinition Height="0.5*" />
                </Grid.RowDefinitions>

                <Border x:Name="ElementVisual"
                        BorderThickness="2"
                        BorderBrush="LightYellow"
                        Background="Black"
                        Padding="2">
                    <Image Source="{Binding}"
                           Stretch="Fill" />
                </Border>
                <Rectangle OpacityMask="{StaticResource ReflectionBrush}"
                           Grid.Row="1"
                           Height="{Binding ActualHeight, ElementName=ElementVisual}">
                    <Rectangle.Fill>
                        <VisualBrush Visual="{Binding ElementName=ElementVisual}">
                            <VisualBrush.RelativeTransform>
                                <ScaleTransform ScaleX="1"
                                                ScaleY="-1"
                                                CenterX="0.5"
                                                CenterY="0.5" />
                            </VisualBrush.RelativeTransform>
                        </VisualBrush>
                    </Rectangle.Fill>
                </Rectangle>
            </Grid>
        </DataTemplate>
        <DataTemplate x:Key="ItemTemplate">
            <Border BorderBrush="#FFB1B1B1"
                    BorderThickness="2"
                    Background="#7FFFFFFF"
                    Padding="0,20,0,0"
                    CornerRadius="3">
                <Image Source="{Binding Image}"
                       HorizontalAlignment="Left"
                       VerticalAlignment="Top"
                       Stretch="Fill" />
            </Border>
        </DataTemplate>
    </Window.Resources>
        
        <controls:ElementFlow x:Name="ElementFlow" 
                              ItemsSource="{DynamicResource DataSource}" 
                              ItemTemplate="{DynamicResource TestDataTemplate}" 
                              HorizontalContentAlignment="Stretch" 
                              VerticalContentAlignment="Stretch"
                              ElementWidth="500"
                              ElementHeight="500"
                              SelectedIndex="0" KeyDown="ElementFlow_KeyDown">
            <controls:ElementFlow.Layout>
                <controls:CoverFlow/>
            </controls:ElementFlow.Layout>

            <controls:ElementFlow.Camera>
                <PerspectiveCamera FieldOfView="45"
											   Position="0,0,5"
											   LookDirection="0,-0.4,-6"
											   UpDirection="0,1,0" />
            </controls:ElementFlow.Camera>
            <controls:ElementFlow.Background>
                <LinearGradientBrush EndPoint="0.5,1"
                                     StartPoint="0.5,0">
                    <GradientStop Color="#FF181818" />
                    <GradientStop Color="#FF7A7A7A"
                                  Offset="0.5" />
                    <GradientStop Color="#FF1A1A1A"
                                  Offset="1" />
                </LinearGradientBrush>
            </controls:ElementFlow.Background>
        </controls:ElementFlow>
</Window>

 

and my cs file

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using FluidKit.Controls;
using FluidKit.Samples;
using MySql.Data;
using MySql.Data.MySqlClient;
using System.Diagnostics;
namespace Cookbook
{
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
    {
        private StringCollection _dataSource; 
        private readonly LayoutBase _layouts = new CoverFlow();
        private Random _randomizer = new Random();
        public MainWindow()
        {
            InitializeComponent();
            ElementFlow.Layout = _layouts;
            ElementFlow.SelectedIndex = 0;
            _dataSource = FindResource("DataSource") as StringCollection;
            
                fill();
            ElementFlow.SelectedIndex = 0;
           
        }
        private void fill() {
            _dataSource = FindResource("DataSource") as StringCollection;
            int x = 0;
            for (x = 0; x < 10; x++)
            _dataSource.Insert(x, "images/1.png");
            ElementFlow.PopoutDistance = 1.5;
        }

        public void next() {
            ElementFlow.SelectedIndex += 1;
            Console.WriteLine(ElementFlow.SelectedIndex);
        }

        private void ElementFlow_KeyDown(object sender, KeyEventArgs e)
        {
            Focus();
            if (e.Key == Key.Space)
                next();
            if (e.Key == Key.Up)
            {
                float temp;
                for (temp = (float)1.5; temp < ElementFlow.PopoutDistance; temp += (float)0.1)
                    ElementFlow.PopoutDistance = temp;

            }
            e.Handled = true;
        }

}
}