Help me Convert this WPF to Silverlight

Discussion in 'Software' started by Xarzu, Dec 29, 2011.

  1. Xarzu

    Xarzu Private E-2

    Help me Convert this WPF to Silverlight

    I am interested in a Charles Petzold C# example that shows how to do a fisheye effect ( http://www.charlespetzold.com/blog/2009/05/Realizing-a-Fisheye-Effect-in-Silverlight.html ). The XAML code samples are in WPF but I want to try this in Silverlight.

    When I try to create the XAML code in Silverlight, the compiler complains in two locations:

    <Style TargetType="{x:Type Button}">
    Error 1 The type 'x:Type' was not found. Verify that you are not missing an assembly reference and that all referenced assemblies have been built.

    <Style.Triggers>
    Error 2 The attachable property 'Triggers' was not found in type 'Style'.

    How do I convert this to Silverlight?
     
  2. PrissyChrissy

    PrissyChrissy Private E-2

    Thus:

    <StackPanel xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">


    You need to check your code. "x" was defined. Are you connected to the internet?


    You just might have to buy his book!:-D
     
  3. PrissyChrissy

    PrissyChrissy Private E-2

    I was being snarky, but I found this further down the page to help you out ... really guy, you gotta read it all!

     
  4. Xarzu

    Xarzu Private E-2

    yeah, I got it running now.
     
  5. Xarzu

    Xarzu Private E-2

    How do you set a default size of a control that you can resize?

    I have been looking at a code sample from Charles Petzold.

    It is from here:

    http://www.charlespetzold.com/blog/2009/05/Realizing-a-Fisheye-Effect-in-Silverlight.html
    it uses mouse over methods to increase the size of button classes.

    I have it working but I want to make some modifications. I want the starting size of the button to be larger. I do not know how much of the code I need to post here to make the issue clear enough. The XAML for the page describes a "FisheyeButton" that is described in a seperate xaml file. Something like this:

    Code:
    <StackPanel x:Name="LayoutRoot" Width="1017" Orientation="Horizontal" Height="253">   
        <src:FisheyeButton Style="{StaticResource btnStyle}" ButtonContent="Button No. 1" />   
    </StackPanel>   

    The functionality of the project is such that if I give the Fisheyebutton a width and height a set size at this loction, the effect where the size of the control the effect of becoming larger does not happen. In other words, if I write in the <src:FisheyeButton... tag above Width="100", then the button does not behave at run time as it should.

    In the same page.xaml file, the btnStyle is defined like this:


    Code:
    <UserControl.Resources >
       <Style x:Key="btnStyle" TargetType="src:FisheyeButton">
          <Setter Property="VerticalAlignment" Value ="Center" />
          <Setter Property="HorizontalAlignment" Value ="Center" />
          <Setter Property="FontSize" Value ="12" />
       </Style >
    </UserControl.Resources >
    I wonder if perhaps at this point, I can add a "Setter" property to define a default starting widh and height for the class.

    The animation, what makes the custom button class grow larger and also return to a normal size, is done in a seperate XAML for the Fisheyebutton class:

    Code:
    <UserControl x:Class="FisheyeButtons6.FisheyeButton" 
                 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"  
                 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" 
                 xmlns:vsm="clr-namespace:System.Windows;assembly=System.Windows" 
                 xmlns:src="clr-namespace:FisheyeButtons6"  
                 mc:Ignorable="d"  
                 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"  
                 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"  
     
                 d:DesignHeight="64" d:DesignWidth="146"> 
        <Grid x:Name="LayoutRoot" Background="White" > 
            <vsm:VisualStateManager.VisualStateGroups> 
                <vsm:VisualStateGroup x:Name="CommonStates"> 
                    <vsm:VisualState x:Name="Normal"> 
                        <Storyboard> 
                            <DoubleAnimation Storyboard.TargetName="presenter" 
                                             Storyboard.TargetProperty="ScaleX" 
                                             To="1" Duration="0:0:0.25" /> 
                            <DoubleAnimation Storyboard.TargetName="presenter" 
                                             Storyboard.TargetProperty="ScaleY" 
                                             To="1" Duration="0:0:0.25" /> 
                        </Storyboard> 
                    </vsm:VisualState> 
                    <vsm:VisualState x:Name="MouseOver"> 
                        <Storyboard> 
                            <DoubleAnimation Storyboard.TargetName="presenter" 
                                             Storyboard.TargetProperty="ScaleX" 
                                             To="3" Duration="0:0:1" /> 
                            <DoubleAnimation Storyboard.TargetName="presenter" 
                                             Storyboard.TargetProperty="ScaleY" 
                                             To="3" Duration="0:0:1" /> 
                        </Storyboard> 
                    </vsm:VisualState> 
                </vsm:VisualStateGroup> 
            </vsm:VisualStateManager.VisualStateGroups> 
     
            <Button> 
                <src:ScalableContentPresenter x:Name="presenter" /> 
            </Button> 
        </Grid> 
    </UserControl> 
    
    
     

MajorGeeks.Com Menu

Downloads All In One Tweaks \ Android \ Anti-Malware \ Anti-Virus \ Appearance \ Backup \ Browsers \ CD\DVD\Blu-Ray \ Covert Ops \ Drive Utilities \ Drivers \ Graphics \ Internet Tools \ Multimedia \ Networking \ Office Tools \ PC Games \ System Tools \ Mac/Apple/Ipad Downloads

Other News: Top Downloads \ News (Tech) \ Off Base (Other Websites News) \ Way Off Base (Offbeat Stories and Pics)

Social: Facebook \ YouTube \ Twitter \ Tumblr \ Pintrest \ RSS Feeds