CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 1 of 1
  1. #1
    Join Date
    Aug 2008
    Posts
    111

    Question WPF Control and Window issue

    Hey all here is a noob question regarding WPF and controls.

    I download the project called FluidKit which comes with a hand full of examples for 3D image effects and just image effects in general.

    Problem I am having is that I just want 1 type of effect out of all of those but I am unsure how to go about making a new project and copy/paste the FluidKit code to my new project just for that needed effect. I am needing to be able to reproduce this a couple of times in my window and not just once as I currently have.

    The code is for the following:

    TransitionTester.xaml

    Which within that has a few settings like:

    Cube (Left to Right)
    Cube (Right to Left>
    Cube (Top to Bottom)
    Cube (Bottom to Top)
    Slide (Left to Right)
    Slide (Right to Left)
    Flip (Left to Right)
    Flip (Right to Left)

    This TransitionTester.xaml looks to be a UserControl.

    So I create a new WPF project and now I have the following forms:

    MainWindow.xaml

    TransitionTester.xaml

    and of course I replace a reference to the fluidkit.dll.

    Bow after copy/pasting the code from the fluidKit project to my new project I end up just having 2 errors which is astonishing to me!

    The error is:
    MainWindow' does not contain a definition for 'SwitchImage' and no extension method 'SwitchImage' accepting a first argument of type 'MainWindow' could be found (are you missing a using directive or an assembly reference?)

    The resource "SlideTransition" could not be resolved

    My MainWindow.xaml code looks like this:
    Code:
        <Window x:Class="flipwindow.MainWindow"
                xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
                xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
                xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
                xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
                xmlns:local="clr-namespace:flipwindow"        
                xmlns:Controls="clr-namespace:FluidKit.Controls;assembly=FluidKit"
                mc:Ignorable="d"
                Title="MainWindow" Height="350" Width="525">
            <Grid>
                <Controls:TransitionPresenter x:Name="_transContainer"
                                              MouseLeftButtonDown="SwitchImage"
                                              RestDuration="0:0:3"
                                              IsLooped="True"
                                              Transition="{StaticResource SlideTransition}">
                    <Image x:Name="_image1"
                           Source="Images/img1.png"
                           Stretch="Fill" />
                    <Image x:Name="_image2"
                           Source="Images/img2.png"
                           Stretch="Fill" />
                    <Image x:Name="_image3"
                           Source="Images/img3.png"
                           Stretch="Fill" />
                </Controls:TransitionPresenter>
            </Grid>
        </Window>
    And the code behind that page looks like this:
    Code:
        namespace flipwindow
        {
            /// <summary>
            /// Interaction logic for MainWindow.xaml
            /// </summary>
            public partial class MainWindow : Window
            {
                private string _backItem = "_image1";
                private string _frontItem = "_image2";
        
                public MainWindow()
                {
                    InitializeComponent();
                    Loaded += TransitionTester_Loaded;
                    //PlayCube();
                }
        
                private void TransitionTester_Loaded(object sender, RoutedEventArgs e)
                {
                    _transContainer.TransitionCompleted += _transContainer_TransitionCompleted;
                }
        
                private void _transContainer_TransitionCompleted(object sender, EventArgs e)
                {
                    SwapFrontAndBack();
                }
        
                private void SwapFrontAndBack()
                {
                    string temp = _frontItem;
                    _frontItem = _backItem;
                    _backItem = temp;
                }
        
                private void PlayCube()
                {
                    CubeTransition transition = Resources["CubeTransition"] as CubeTransition;
                    //transition.Rotation = Direction.LeftToRight;
                    //transition.Rotation = Direction.RightToLeft;
                    //transition.Rotation = Direction.TopToBottom;
                    transition.Rotation = Direction.BottomToTop;
        
                    _transContainer.Transition = transition;
                    _transContainer.ApplyTransition(_frontItem, _backItem);
                }
            }
        }
    Layout looks like this:


    And my MainWindow.xaml Design looks fine as well:



    When comparing it with the original FluidKit window:



    So any help to help me fix this error would be great!

    Last edited by StealthRT; November 19th, 2017 at 02:49 PM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured