David G

David G

  • 1.4k
  • 224
  • 13.9k

WPF Control and Window issue

Nov 19 2017 2:36 PM
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.
 
After copy/pasting the code from the fluidKit project to my new project I end up just having this error 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
  1. "flipwindow.MainWindow"  
  2.             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
  3.             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"  
  4.             xmlns:d="http://schemas.microsoft.com/expression/blend/2008"  
  5.             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  
  6.             xmlns:local="clr-namespace:flipwindow"          
  7.             xmlns:Controls="clr-namespace:FluidKit.Controls;assembly=FluidKit"  
  8.             mc:Ignorable="d"  
  9.             Title="MainWindow" Height="350" Width="525">  
  10.           
  11.             "_transContainer"  
  12.                                           MouseLeftButtonDown="SwitchImage"  
  13.                                           RestDuration="0:0:3"  
  14.                                           IsLooped="True"  
  15.                                           Transition="{StaticResource SlideTransition}">  
  16.                 "_image1"  
  17.                        Source="Images/img1.png"  
  18.                        Stretch="Fill" />  
  19.                 "_image2"  
  20.                        Source="Images/img2.png"  
  21.                        Stretch="Fill" />  
  22.                 "_image3"  
  23.                        Source="Images/img3.png"  
  24.                        Stretch="Fill" />  
  25.               
  26.           
  27.       
And the code behind that page looks like this:
  1. namespace flipwindow  
  2.     {  
  3.         ///   
  4.         /// Interaction logic for MainWindow.xaml  
  5.         ///   
  6.         public partial class MainWindow : Window  
  7.         {  
  8.             private string _backItem = "_image1";  
  9.             private string _frontItem = "_image2";  
  10.       
  11.             public MainWindow()  
  12.             {  
  13.                 InitializeComponent();  
  14.                 Loaded += TransitionTester_Loaded;  
  15.                 //PlayCube();  
  16.             }  
  17.       
  18.             private void TransitionTester_Loaded(object sender, RoutedEventArgs e)  
  19.             {  
  20.                 _transContainer.TransitionCompleted += _transContainer_TransitionCompleted;  
  21.             }  
  22.       
  23.             private void _transContainer_TransitionCompleted(object sender, EventArgs e)  
  24.             {  
  25.                 SwapFrontAndBack();  
  26.             }  
  27.       
  28.             private void SwapFrontAndBack()  
  29.             {  
  30.                 string temp = _frontItem;  
  31.                 _frontItem = _backItem;  
  32.                 _backItem = temp;  
  33.             }  
  34.       
  35.             private void PlayCube()  
  36.             {  
  37.                 CubeTransition transition = Resources["CubeTransition"as CubeTransition;  
  38.                 //transition.Rotation = Direction.LeftToRight;  
  39.                 //transition.Rotation = Direction.RightToLeft;  
  40.                 //transition.Rotation = Direction.TopToBottom;  
  41.                 transition.Rotation = Direction.BottomToTop;  
  42.       
  43.                 _transContainer.Transition = transition;  
  44.                 _transContainer.ApplyTransition(_frontItem, _backItem);  
  45.             }  
  46.         }  
  47.     }  
Layout looks like this:
https://i.stack.imgur.com/wYPDb.png
 
And my MainWindow.xaml Design looks fine as well:
https://i.stack.imgur.com/xmsle.png
 
When comparing it with the original FluidKit window:
https://i.stack.imgur.com/iF9ku.png
 
So any help to help me fix this error would be great!
https://i.stack.imgur.com/LFtp5.png