User avatar
sfernandez
Site Admin
Posts: 1912
Joined: 22 Dec 2011, 19:20

Re: Data Binding

14 Aug 2014, 20:16

Could you please export your test scene (don't include dependencies, only the assets under the Tutorial folder) and attach it here so I can find what is wrong?
 
movra
Posts: 70
Joined: 02 Apr 2014, 20:35

Re: Data Binding

14 Aug 2014, 20:20

I think S0l0 means that the behavior for Button states such as hover and pressed are gone and wants to know how to get them back. The two custom animations should be triggered from the click and release events.

Maybe some useful info in this control template tutorial with visual state manager:
http://jeremybytes.blogspot.nl/2012/07/ ... ntrol.html
 
S0L0
Topic Author
Posts: 18
Joined: 07 Aug 2014, 14:49

Re: Data Binding

14 Aug 2014, 20:23

How can new button animations be added to a resourcedictionary? Is there away to setup the button animations using Blend? ie, pick a state than using the storyboard, color picker, etc.

    <VisualStateManager.VisualStateGroups>

      <VisualStateGroup x:Name="CommonStates">
      
        <VisualStateGroup.Transitions>
        
            <VisualTransition To="Pressed" GeneratedDuration="0:0:0.01" />
        
            <VisualTransition To="Focused" GeneratedDuration="0:0:0.5" />
        
            <VisualTransition From="Pressed" To="Focused" GeneratedDuration="0:0:0.01" />
                                  
            <VisualTransition From="Focused" To="Normal" GeneratedDuration="0:0:1.5">

        </VisualStateGroup.Transitions>
      
            <VisualState x:Name="Normal" />
    
            <VisualState x:Name="Focused">
            
               <Button.RenderTransform>
                  <ScaleTransform ScaleX="2.0" ScaleY="2.0"></ScaleTransform>
               </Button.RenderTransform>
            
            <VisualState x:Name="Pressed">
        
      </VisualStateGroup>

    </VisualStateManager.VisualStateGroups>


<ResourceDictionary
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
 
    <ControlTemplate x:Key="helpicon" TargetType="Button">
          <Viewbox xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
          <Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Name="svg3089" Width="512" Height="512"><Canvas.RenderTransform><TranslateTransform X="0" Y="0"/></Canvas.RenderTransform><Canvas.Resources/><!--Unknown tag: metadata--><!--Unknown tag: sodipodi:namedview--><Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path3091" Fill="#000000" Data="m0 0h512v512h-512z"/><Canvas Name="g3093"><Canvas.RenderTransform><MatrixTransform Matrix="15 0 0 15 -4304 -2204"/></Canvas.RenderTransform><Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path3097" Fill="#FFFFFFFF" Data="m304 148c-8.8366 0-16 7.1634-16 16 0 8.8366 7.1634 16 16 16 8.8366 0 16-7.1634 16-16 0-8.8366-7.1634-16-16-16zm0 4c6.6274 0 12 5.3726 12 12 0 6.6274-5.3726 12-12 12-6.6274 0-12-5.3726-12-12 0-6.6274 5.3726-12 12-12z"/></Canvas><Canvas Name="g3099"><Canvas Name="g3101"><Canvas.RenderTransform><MatrixTransform Matrix="30 0 0 30 -16304 -21954.866"/></Canvas.RenderTransform></Canvas><Canvas Name="g3105"><Canvas.RenderTransform><MatrixTransform Matrix="15 0 0 15 -8864 -13489.433"/></Canvas.RenderTransform><Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path3107" Fill="#FFFFFFFF" Data="m608 454c-4.4183 0-8 2.6863-8 6 0 2 4 2 4 0 0-1.1046 1.7908-2 4-2 2.2092 0 4 .8954 4 2 0 1.1046-2 1-4 2-.125 .0625-.2319 .1418-.3125 .2188-1.6523 1.0469-1.6875 2.8429-1.6875 3.7812v1c0 1.108 .892 2 2 2 1.108 0 2-.892 2-2v-1c0-3 6-2.6863 6-6 0-3.3137-3.5817-6-8-6z"><Path.RenderTransform><TranslateTransform X="0" Y="452.36218"/></Path.RenderTransform></Path><Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path3109" Fill="#FFFFFFFF" Data="m608 470a2 2 0 0 1 2 2 2 2 0 0 1 -2 2 2 2 0 0 1 -2-2 2 2 0 0 1 2-2"><Path.RenderTransform><TranslateTransform X="0" Y="452.36218"/></Path.RenderTransform></Path></Canvas></Canvas></Canvas>
          </Viewbox>
    </ControlTemplate>
    
    <ControlTemplate x:Key="cancelicon" TargetType="Button">
          <Viewbox xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
          <Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Name="svg2" Width="512" Height="512"><Canvas.RenderTransform><TranslateTransform X="0" Y="0"/></Canvas.RenderTransform><Canvas.Resources/><!--Unknown tag: metadata--><!--Unknown tag: sodipodi:namedview--><Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path4" Fill="#000000" Data="m0 0h512v512h-512z"/><Canvas Name="g6"><Canvas.RenderTransform><MatrixTransform Matrix="15 0 0 15 -3764 -2204"/></Canvas.RenderTransform></Canvas><Canvas Name="g10"><Canvas.RenderTransform><MatrixTransform Matrix="30 0 0 30 -14144 -21954.866"/></Canvas.RenderTransform><Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path14" Fill="#FFFFFFFF" Data="m477.2108 736.3717c-.6099 .1145-1.5089 1.1579-1.1126 1.554l2.4386 2.4378-2.4386 2.4377c-.4877 .4875 .9755 1.9502 1.4632 1.4626l2.4387-2.4377 2.4386 2.4377c.4877 .4876 1.9509-.9751 1.4632-1.4626l-2.4386-2.4377 2.4386-2.4378c.4877-.4875-.9755-1.9501-1.4632-1.4626l-2.4386 2.4377-2.4386-2.4377c-.0915-.091-.2098-.1178-.3506-.091z"/></Canvas><Canvas Name="g16"><Canvas.RenderTransform><MatrixTransform Matrix="15 0 0 15 -3764 -2204"/></Canvas.RenderTransform><Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path18" Fill="#FFFFFFFF" Data="m268 148c-8.8366 0-16 7.1634-16 16 0 8.8366 7.1634 16 16 16 8.8366 0 16-7.1634 16-16 0-8.8366-7.1634-16-16-16zm0 4c6.6274 0 12 5.3726 12 12 0 6.6274-5.3726 12-12 12-6.6274 0-12-5.3726-12-12 0-6.6274 5.3726-12 12-12z"/></Canvas></Canvas>
          </Viewbox>
    </ControlTemplate>
    
    <ControlTemplate x:Key="tinkericon" TargetType="Button">
          <Viewbox xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
          <Canvas xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" Name="svg2" Width="512" Height="512"><Canvas.RenderTransform><TranslateTransform X="0" Y="0"/></Canvas.RenderTransform><Canvas.Resources/><!--Unknown tag: metadata--><!--Unknown tag: sodipodi:namedview--><Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path4" Fill="#000000" Data="m0 0h512v512h-512z"/><Canvas Name="g6"><Canvas.RenderTransform><MatrixTransform Matrix="18.68858 0 0 18.68858 -1595.78291 -44231.51749"/></Canvas.RenderTransform><Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path8" Fill="#FFFFFFFF" Stroke="#FF000000" Data="m103.909 2368.7278c1.593-1.5928 3.9978-1.8378 5.8765-.8023l-3.1443 3.1442c-.5539.5539-.5751 1.4633-.0434 1.995s1.4194.4888 1.9733-.065l3.1442-3.1443c1.0353 1.8786.7906 4.2836-.8023 5.8765-1.2245 1.2245-2.9356 1.6734-4.5104 1.3444l-10.6599 10.6598c.3287 1.5747-.1199 3.2859-1.3443 4.5105-1.593 1.5927-3.9979 1.8375-5.8765.8022l3.1442-3.1443c.5539-.5538.5968-1.4416.0651-1.9733s-1.4411-.5105-1.9949.043l-3.1443 3.1442c-1.0354-1.8786-.7906-4.2835.8024-5.8764 1.2245-1.2244 2.9512-1.6575 4.532-1.3227l10.6597-10.66c-.335-1.5809.0984-3.3073 1.3229-4.5318z"/><Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path10" Fill="#FFFFFFFF" Stroke="#FF000000" Data="m110.1284 2393.5471-4.7418-3.0331 .293-2.0209-7.6594-7.6594 1.4595-1.4594 7.6594 7.6594 2.0208-.2931 3.0332 4.7419z"/><Path xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Name="path12" Fill="#FFFFFFFF" Stroke="#FF000000" Data="m94.6169 2380.6983c-.0435-1.4887-1.1192-2.5644-2.6075-2.6076l-4.7391-4.7391c-3.3415-3.3417 1.1045-8.2646 4.6846-4.6845l4.7611 4.761c.0626 1.4514 1.1119 2.5009 2.5633 2.5634 1.1714 0 2.2544 1.2812 1.1712 2.3645l-3.4475 3.4467c-1.0421 1.0424-2.5168.1512-2.3862-1.1044z"/></Canvas></Canvas>
          </Viewbox>
    </ControlTemplate>
 
</ResourceDictionary>

 
S0L0
Topic Author
Posts: 18
Joined: 07 Aug 2014, 14:49

Re: Data Binding

15 Aug 2014, 00:48

It seems customizing buttons in blend is possible :D , this tutorial explains it really well:

http://www.youtube.com/watch?v=2cfFQvGejRA
 
User avatar
sfernandez
Site Admin
Posts: 1912
Joined: 22 Dec 2011, 19:20

Re: Data Binding

16 Aug 2014, 11:57

Here you can find a newer video explaining how to define the visual states of a control: https://www.youtube.com/watch?v=m0PlkF5i6uw

I think using Visual States (instead of using triggers in the template) for defining the aspect of a control is simpler and better to understand for people that doesn't know anything about WPF/SL.
 
movra
Posts: 70
Joined: 02 Apr 2014, 20:35

Re: Data Binding

16 Aug 2014, 15:06

From the example on the first page, can you bind "helpicon" to a datacontext property in XAML?

Data structure:
- A collection of Panels is set as the DataContext of the XAML.
- Each Panel object contains a collection of Options.
- Each Option object has a OptionIcon property that returns a string matching the key of the ControlTemplate in the ResourceDictionary.
<ResourceDictionary.MergedDictionaries>
    <ResourceDictionary x:Name="IconResource" Source="iconresource.xaml"/>
</ResourceDictionary.MergedDictionaries>

...

<DataTemplate x:Key="PanelsItemTemplate">   
   <ItemsControl x:Name="Options" ItemsSource="{Binding Options}">
       <ItemsControl.ItemTemplate>
           <DataTemplate>			
               <Button Template="[[Get the icon with x:Key == OptionIcon]]" />

...

<ListBox ItemsSource="{Binding Panels}" ItemTemplate="{StaticResource PanelsItemTemplate}" />

Who is online

Users browsing this forum: No registered users and 1 guest