Search Results

Search found 6091 results on 244 pages for 'wpf storyboard'.

Page 1/244 | 1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >

  • Wpf: Storyboard.TargetName works, but Setter TargetName doesn't.

    - by MainMa
    Hi, Let's say we have a XAML code like this: <Style TargetType="{x:Type ListBoxItem}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type ListBoxItem}"> <Border HorizontalAlignment="Center" VerticalAlignment="Center"> <Border.LayoutTransform> <!--We are rotating randomly each image. Selected one will be rotated to 45°.--> <RotateTransform Angle="{Binding RandomAngle}" x:Name="globalRotation"/> </Border.LayoutTransform> <Grid> <Image Source="{Binding ImageLocation}" Stretch="None" /> <TextBlock x:Name="title" Text="{Binding Title}" /> </Grid> </Border> <ControlTemplate.Triggers> <Trigger Property="IsSelected" Value="True"> <Setter TargetName="title" Property="Visibility" Value="Visible"/> <!--The next line will not compile.--> <Setter TargetName="globalRotation" Property="Angle" Value="45"/> <Trigger.EnterActions> <BeginStoryboard> <Storyboard> <!--This compiles well.--> <DoubleAnimation Storyboard.TargetName="globalRotation" Storyboard.TargetProperty="Angle" To="45" Duration="00:00:03"/> </Storyboard> </BeginStoryboard> </Trigger.EnterActions> </Trigger> </ControlTemplate.Triggers> </ControlTemplate> </Setter.Value> </Setter> </Style> This code is intended to display a set of images in a listbox. Each image has a random rotation, but when selected, rotates to 45 degrees. Rotating selected image through a storyboard works well. I just specify Storyboard.TargetName and it rotates the image when selected (Trigger.ExitActions is omitted to make the code shorter). Now, if I want, instead of using a storyboard, assign 45 degrees value directly, I can't do that, because <Setter TargetName="globalRotation" Property="Angle" Value="45"/>: it compiles with "Cannot find the Trigger target 'globalRotation'. (The target must appear before any Setters, Triggers, or Conditions that use it.)" error. What happens? I suppose that Storyboard.TargetName is evaluated during runtime, so let me compile it. Is it right? How to make it work with just a setter, without using a storyboard?

    Read the article

  • WPF Storyboard flicker issue

    - by Vinjamuri
    With the code below, the control flickers whenever the image is changed for MouseOver/MousePressed? I am using Storyboard and Double animation.The image display is very smooth with WPF Triggers but not with Storyboard. Can anyone help me to fix this issue? <Style TargetType="{x:Type local:ButtonControl}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type local:ButtonControl}"> <Grid> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Normal"> <Storyboard> <DoubleAnimation Duration="00:00:00.20" Storyboard.TargetName="imgNormal" Storyboard.TargetProperty="Opacity" To="1" /> </Storyboard> </VisualState> <VisualState x:Name="MouseOver"> <Storyboard> <DoubleAnimation Duration="00:00:00.20" Storyboard.TargetName="imgOver" Storyboard.TargetProperty="Opacity" To="1" /> </Storyboard> </VisualState> <VisualState x:Name="Disabled"> <Storyboard> <DoubleAnimation Duration="00:00:00.20" Storyboard.TargetName="imgDisable" Storyboard.TargetProperty="Opacity" To="1" /> </Storyboard> </VisualState> <VisualState x:Name="Pressed"> <Storyboard> <DoubleAnimation Duration="00:00:00.20" Storyboard.TargetName="imgPress" Storyboard.TargetProperty="Opacity" To="1" /> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Grid> <Border x:Name="imgNormal" Opacity="0"> <Image Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=NormalImage}" Stretch="UniformToFill"/> </Border> </Grid> <Grid> <Border x:Name="imgOver" Opacity="0"> <Image Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=MouseOverImage}" Stretch="UniformToFill"/> </Border> </Grid> <Grid> <Border x:Name="imgDisable" Opacity="0"> <Image Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DisableImage}" Stretch="UniformToFill"/> </Border> </Grid> <Grid> <Border x:Name="imgPress" Opacity="0"> <Image Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=MousePressImage}" Stretch="UniformToFill"/> </Border> </Grid> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>

    Read the article

  • Storyboard apply to all labels

    - by ThitoO
    Hi everyone ! I whant to apply a little storyboard to a collection of labels in my window. My storyboard is like that : <Storyboard x:Key="Storyboard1" AutoReverse="True" RepeatBehavior="Forever"> <ColorAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="label" Storyboard.TargetProperty="(Label.Foreground).(SolidColorBrush.Color)"> <SplineColorKeyFrame KeyTime="00:00:00.1000000" Value="#FFFFFF"/> </ColorAnimationUsingKeyFrames> </Storyboard> I have a window composed of that : <Grid Background="#FF000000"> <Viewbox HorizontalAlignment="Center" VerticalAlignment="Center" Stretch="Uniform"> <UniformGrid x:Name="grid" Background="#FF000000" /> </Viewbox> </Grid> When I want to start my storyboard I do that : Storyboard.SetTarget( _stb, myLabel ); _stb.Begin(); where _std is my storyboard loaded by the window's resources. The animation works fine, but on all labels (not only the one I want). I tried to switch SetTarget by SetTargetName but labels are created into my window by the constructor and names can not be founded when I try "SetTargetName". Do you have any ideas ? Thanks :) ------------ Edit : We asked me to be more descriptive -------------------------------------------------------------------- Label are not created directly in the xaml, they are created by the constructor of the window : public SpellerWindow(IKeyboard keyboard, int colomnNumber, SolidColorBrush background, SolidColorBrush foreground ) { InitializeComponent(); grid.Columns = colomnNumber; int i = 0; foreach( IKey key in keyboard.Zones.Default.Keys ) { Label lb = new Label(); lb.Foreground = foreground; lb.Name = "label"+(i++).ToString(); lb.Content = key.ActualKeys[keyboard.CurrentMode].UpLabel; lb.HorizontalAlignment = HorizontalAlignment.Center; lb.VerticalAlignment = VerticalAlignment.Center; Viewbox box = new Viewbox(); box.Stretch = Stretch.Fill; box.Child = lb; box.Tag = key; grid.Children.Add( box ); } } Animations are started by an event handler : void Highlighter_StartAnimation( object sender, HiEventArgs e ) { Storyboard stb; if( !_anims.TryGetValue( e.Step.Animation.Name, out stb ) ) { stb = (Storyboard)_window.FindResource( e.Step.Animation.Name ); _anims.Add( e.Step.Animation.Name, stb ); } DoAnimations( _zones[e.Step.Zone], stb ); } Finally, animations are started by DoAnimations : void DoAnimations( List<Label> labels, Storyboard stb ) { foreach( Label lb in labels ) { Storyboard.SetTarget( stb, lb ); stb.Begin(); } } I want to highlight a collection of labels, but all labels are flashing. I don't know why, but I try to create a label into the Xaml directly, and set a Storyboard.TargetName (bound to the name of the label) in the Xaml of the storyboard. And it's working ... Now you know everything. Thanks for you help :)

    Read the article

  • WPF binding to current class property

    - by AnD
    Hello, I have a problem that i cant solve :( I have a user control (xaml file and cs file) in xaml it's like: <UserControl 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" mc:Ignorable="d" x:Class="Demo.CtrlContent" x:Name="UserControl" d:DesignWidth="598.333" d:DesignHeight="179.133" xmlns:Demo="clr-namespace:Demo" > <UserControl.Resources> <Storyboard x:Key="SBSmall"> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="border" Storyboard.TargetProperty="(FrameworkElement.Width)"> <SplineDoubleKeyFrame KeyTime="00:00:01" Value="I WANT TO BIND VALUE HERE"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </UserControl.Resources> <Border BorderBrush="#FFC2C0C1" CornerRadius="3,3,3,3" BorderThickness="1,1,1,1" RenderTransformOrigin="0.5,0.5" x:Name="border" Margin="1,3,1,3" HorizontalAlignment="Left" VerticalAlignment="Top" Width="300"> and .cs file: public partial class CtrlContent { private mindef W { get { return (mindef) Window.GetWindow(this); } } public double MedWidth { // I WANT BIND THIS VALUE GO TO STORYBOARD VALUE IN XAML ABOVE get { double actualW; if(W == null) actualW = SystemParameters.PrimaryScreenWidth; else actualW = W.WrapMain.ActualWidth; return actualW - border.Margin.Left - border.Margin.Right; } } public double SmlWidth { get { return MedWidth / 2; } } public CtrlContent () { this.InitializeComponent(); } public CtrlContent (Content content) { this.InitializeComponent(); Document = content; } } in my .cs file there's a property called MedWidth, and in XAML file there's a storyboard called: SBSmall I want to bind my storyboard value to my property in class ctrlcontent. *the idea is, the storyboard is an animation to resize the control to a certain width depends on its parent container (the width is dynamic) anybody? please :) thanks!

    Read the article

  • WPF Storyboard delay in playing wma files

    - by Rita
    I'm a complete beginner in WPF and have an app that uses StoryBoard to play a sound. public void PlaySound() { MediaElement m = (MediaElement)audio.FindName("MySound.wma"); m.IsMuted = false; FrameworkElement audioKey = (FrameworkElement)keys.FindName("MySound"); Storyboard s = (Storyboard)audioKey.FindResource("MySound.wma"); s.Begin(audioKey); } <Storyboard x:Key="MySound.wma"> <MediaTimeline d:DesignTimeNaturalDuration="1.615" BeginTime="00:00:00" Storyboard.TargetName="MySound.wma" Source="Audio\MySound.wma"/> </Storyboard> I have a horrible lag and sometimes it takes good 10 seconds for the sound to be played. I suspect this has something to do with the fact that no matter how long I wait - The sound doesn't get played until after I leave the function. I don't understand it. I call Begin, and nothing happens. Is there a way to replace this method, or StoryBoard object with something that plays instantly and without a lag?

    Read the article

  • Storyboard as timer in WPF

    - by Adrian
    Hi, I'm trying to do smooth animation in procedural code. For this (in Silverlight at least), it's recommended to use the Storyboard timer rather than a DispatcherTimer. So I use something like this: Storyboard _LoopTimer = new Storyboard(); public void StartAnimation() { _LoopTimer.Duration = TimeSpan.FromMilliseconds(0); _LoopTimer.Completed += new EventHandler(MainLoop); _LoopTimer.Begin(); } void MainLoop(object sender, EventArgs e) { // Do animation stuff here // Continue storyboard timer _LoopTimer.Begin(); } And in Silverlight, this works fine. But in WPF, I only hit MainLoop() once. Setting RepeatBehaviour to Forever doesn't help, either. So what's the right way to do this in WPF with a Storyboard? Thanks very much.

    Read the article

  • WPF storyboard animation issue when using VisualBrush

    - by Flack
    Hey guys, I was playing around with storyboards, a flipping animation, and visual brushes. I have encountered an issue though. Below is the xaml and code-behind of a small sample I quickly put together to try to demonstrate the problem. When you first start the app, you are presented with a red square and two buttons. If you click the "Flip" button, the red square will "flip" over and a blue one will appear. In reality, all that is happening is that the scale of the width of the StackPanel that the red square is in is being decreased until it reaches zero and then the StackPanel where a blue square is, whose width is initially scaled to zero, has its width increased. If you click the "Flip" button a few times, the animation looks ok and smooth. Now, if you hit the "Reflection" button, a reflection of the red/blue buttons is added to their respective StackPanels. Hitting the "Flip" button now will still cause the flip animation but it is no longer a smooth animation. The StackPanels width often does not shrink to zero. The width shrinks somewhat but then just stops before being completely invisible. Then the other StackPanel appears as usual. The only thing that changed was adding the reflection, which is just a VisualBrush. Below is the code. Does anyone have any idea why the animations are different between the two cases (stalling in the second case)? Thanks. <Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xml:lang="en-US" xmlns:d="http://schemas.microsoft.com/expression/blend/2006" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" x:Class="WpfFlipTest.Window1" x:Name="Window" Title="Window1" Width="214" Height="224"> <Window.Resources> <Storyboard x:Key="sbFlip"> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="redStack" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)"> <SplineDoubleKeyFrame KeyTime="00:00:00.4" Value="0"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.4" Storyboard.TargetName="blueStack" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)"> <SplineDoubleKeyFrame KeyTime="00:00:00.8" Value="1"/> </DoubleAnimationUsingKeyFrames> </Storyboard> <Storyboard x:Key="sbFlipBack"> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="blueStack" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)"> <SplineDoubleKeyFrame KeyTime="00:00:00.4" Value="0"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.4" Storyboard.TargetName="redStack" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)"> <SplineDoubleKeyFrame KeyTime="00:00:00.8" Value="1"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </Window.Resources> <Grid x:Name="LayoutRoot" Background="Gray"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <StackPanel Name="redStack" Grid.Row="0" Grid.Column="0" RenderTransformOrigin="0.5,0.5"> <StackPanel.RenderTransform> <ScaleTransform/> </StackPanel.RenderTransform> <Border Name="redBorder" BorderBrush="Transparent" BorderThickness="4" Width="Auto" Height="Auto"> <Button Margin="0" Name="redButton" Height="75" Background="Red" Width="105" /> </Border> <Border Width="{Binding ElementName=redBorder, Path=ActualWidth}" Height="{Binding ElementName=redBorder, Path=ActualHeight}" Opacity="0.2" BorderBrush="Transparent" BorderThickness="4" Name="redRefelction" Visibility="Collapsed"> <Border.OpacityMask> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <LinearGradientBrush.GradientStops> <GradientStop Offset="0" Color="Black"/> <GradientStop Offset=".6" Color="Transparent"/> </LinearGradientBrush.GradientStops> </LinearGradientBrush> </Border.OpacityMask> <Border.Background> <VisualBrush Visual="{Binding ElementName=redButton}"> <VisualBrush.Transform> <ScaleTransform ScaleX="1" ScaleY="-1" CenterX="52.5" CenterY="37.5" /> </VisualBrush.Transform> </VisualBrush> </Border.Background> </Border> </StackPanel> <StackPanel Name="blueStack" Grid.Row="0" Grid.Column="0" RenderTransformOrigin="0.5,0.5"> <StackPanel.RenderTransform> <ScaleTransform ScaleX="0"/> </StackPanel.RenderTransform> <Border Name="blueBorder" BorderBrush="Transparent" BorderThickness="4" Width="Auto" Height="Auto"> <Button Grid.Row="0" Grid.Column="1" Margin="0" Width="105" Background="Blue" Name="blueButton" Height="75"/> </Border> <Border Width="{Binding ElementName=blueBorder, Path=ActualWidth}" Height="{Binding ElementName=blueBorder, Path=ActualHeight}" Opacity="0.2" BorderBrush="Transparent" BorderThickness="4" Name="blueRefelction" Visibility="Collapsed"> <Border.OpacityMask> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <LinearGradientBrush.GradientStops> <GradientStop Offset="0" Color="Black"/> <GradientStop Offset=".6" Color="Transparent"/> </LinearGradientBrush.GradientStops> </LinearGradientBrush> </Border.OpacityMask> <Border.Background> <VisualBrush Visual="{Binding ElementName=blueButton}"> <VisualBrush.Transform> <ScaleTransform ScaleX="1" ScaleY="-1" CenterX="52.5" CenterY="37.5" /> </VisualBrush.Transform> </VisualBrush> </Border.Background> </Border> </StackPanel> <Button Grid.Row="1" Click="FlipButton_Click" Height="19.45" HorizontalAlignment="Left" VerticalAlignment="Top" Width="76">Flip</Button> <Button Grid.Row="0" Grid.Column="1" Click="ReflectionButton_Click" Height="19.45" HorizontalAlignment="Left" VerticalAlignment="Top" Width="76">Reflection</Button> </Grid> </Window> Here are the button click handlers: 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 System.Windows.Media.Animation; namespace WpfFlipTest { public partial class Window1 : Window { public Window1() { InitializeComponent(); } bool flipped = false; private void FlipButton_Click(object sender, RoutedEventArgs e) { Storyboard sbFlip = (Storyboard)Resources["sbFlip"]; Storyboard sbFlipBack = (Storyboard)Resources["sbFlipBack"]; if (flipped) { sbFlipBack.Begin(); flipped = false; } else { sbFlip.Begin(); flipped = true; } } bool reflection = false; private void ReflectionButton_Click(object sender, RoutedEventArgs e) { if (reflection) { reflection = false; redRefelction.Visibility = Visibility.Collapsed; blueRefelction.Visibility = Visibility.Collapsed; } else { reflection = true; redRefelction.Visibility = Visibility.Visible; blueRefelction.Visibility = Visibility.Visible; } } } } UPDATE: I have been testing this some more to try to find out what is causing the issue I am seeing and I believe I found what is causing the issue. Below I have pasted new xaml and code-behind. The new sample below is very similar to the original sample, with a few minor modifications. The xaml basically consists of two stack panels, each containing two borders. The second border in each stack panel is a visual brush (a reflection of the border above it). Now, when I click the "Flip" button, one stack panel gets its ScaleX reduced to zero, while the second stack panel, whose initial ScaleX is zero, gets its ScaleX increased to 1. This animation gives the illusion of flipping. There are also two textblocks which display the scale factor of each stack panel. I added those to try to diagnose my issue. The issue is (as described in the oringal post) that the flipping animation is not smooth. Every time I hit the flip button, the animation starts but whenever the ScaleX factor gets to around .14 to .16, the animation looks like it stalls and the stack panels never have there ScaleX reduced to zero, so they never totally disappear. Now, the strange thing is that if I change the Width/Height properties of the "frontBorder" and "backBorder" borders defined below to use explict values instead of Auto, such as Width=105 and Height=75 (to match the button in the border) everything works fine. The animation stutters the first two or three times I run it but after that the flips are smooth and flawless. (BTW, when an animation is run for the first time, is there something going on in the background, some sort of initialization, that causes it to be a little slow the first time?) Is it possible that the Auto Width/Height of the borders are causing the issue? I can reproduce it everytime but I am not sure why Auto Width/Height would be a problem. Below is the sample. Thanks for the help. <Window x:Class="FlipTest.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <Window.Resources> <Storyboard x:Key="sbFlip"> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="front" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)"> <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="0"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.5" Storyboard.TargetName="back" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)"> <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="1"/> </DoubleAnimationUsingKeyFrames> </Storyboard> <Storyboard x:Key="sbFlipBack"> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00" Storyboard.TargetName="back" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)"> <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="0"/> </DoubleAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames BeginTime="00:00:00.5" Storyboard.TargetName="front" Storyboard.TargetProperty="(UIElement.RenderTransform).(ScaleTransform.ScaleX)"> <SplineDoubleKeyFrame KeyTime="00:00:00.5" Value="1"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </Window.Resources> <Grid x:Name="LayoutRoot" Background="White" ShowGridLines="True"> <Grid.RowDefinitions> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> <RowDefinition Height="Auto"/> </Grid.RowDefinitions> <Grid.ColumnDefinitions> <ColumnDefinition Width="Auto"/> <ColumnDefinition Width="Auto"/> </Grid.ColumnDefinitions> <StackPanel x:Name="front" RenderTransformOrigin="0.5,0.5"> <StackPanel.RenderTransform> <ScaleTransform/> </StackPanel.RenderTransform> <Border Name="frontBorder" BorderBrush="Yellow" BorderThickness="2" Width="Auto" Height="Auto"> <Button Margin="0" Name="redButton" Height="75" Background="Red" Width="105" Click="FlipButton_Click"/> </Border> <Border Width="{Binding ElementName=frontBorder, Path=ActualWidth}" Height="{Binding ElementName=frontBorder, Path=ActualHeight}" Opacity="0.2" BorderBrush="Transparent"> <Border.OpacityMask> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <LinearGradientBrush.GradientStops> <GradientStop Offset="0" Color="Black"/> <GradientStop Offset=".6" Color="Transparent"/> </LinearGradientBrush.GradientStops> </LinearGradientBrush> </Border.OpacityMask> <Border.Background> <VisualBrush Visual="{Binding ElementName=frontBorder}"> <VisualBrush.Transform> <ScaleTransform ScaleX="1" ScaleY="-1" CenterX="52.5" CenterY="37.5" /> </VisualBrush.Transform> </VisualBrush> </Border.Background> </Border> </StackPanel> <StackPanel x:Name="back" RenderTransformOrigin="0.5,0.5"> <StackPanel.RenderTransform> <ScaleTransform ScaleX="0"/> </StackPanel.RenderTransform> <Border Name="backBorder" BorderBrush="Yellow" BorderThickness="2" Width="Auto" Height="Auto"> <Button Margin="0" Width="105" Background="Blue" Name="blueButton" Height="75" Click="FlipButton_Click"/> </Border> <Border Width="{Binding ElementName=backBorder, Path=ActualWidth}" Height="{Binding ElementName=backBorder, Path=ActualHeight}" Opacity="0.2" BorderBrush="Transparent"> <Border.OpacityMask> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <LinearGradientBrush.GradientStops> <GradientStop Offset="0" Color="Black"/> <GradientStop Offset=".6" Color="Transparent"/> </LinearGradientBrush.GradientStops> </LinearGradientBrush> </Border.OpacityMask> <Border.Background> <VisualBrush Visual="{Binding ElementName=backBorder}"> <VisualBrush.Transform> <ScaleTransform ScaleX="1" ScaleY="-1" CenterX="52.5" CenterY="37.5" /> </VisualBrush.Transform> </VisualBrush> </Border.Background> </Border> </StackPanel> <Button Grid.Row="1" Click="FlipButton_Click" Height="19.45" HorizontalAlignment="Left" VerticalAlignment="Top" Width="76">Flip</Button> <TextBlock Grid.Row="2" Grid.Column="0" Foreground="DarkRed" Height="19.45" HorizontalAlignment="Left" VerticalAlignment="Top" Width="76" Text="{Binding ElementName=front, Path=(UIElement.RenderTransform).(ScaleTransform.ScaleX)}"/> <TextBlock Grid.Row="3" Grid.Column="0" Foreground="DarkBlue" Height="19.45" HorizontalAlignment="Left" VerticalAlignment="Top" Width="76" Text="{Binding ElementName=back, Path=(UIElement.RenderTransform).(ScaleTransform.ScaleX)}"/> </Grid> </Window> Code-behind: 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 System.Windows.Media.Animation; namespace FlipTest { /// <summary> /// Interaction logic for Window1.xaml /// </summary> public partial class Window1 : Window { public Window1() { InitializeComponent(); } bool flipped = false; private void FlipButton_Click(object sender, RoutedEventArgs e) { Storyboard sbFlip = (Storyboard)Resources["sbFlip"]; Storyboard sbFlipBack = (Storyboard)Resources["sbFlipBack"]; if (flipped) { sbFlipBack.Begin(); flipped = false; } else { sbFlip.Begin(); flipped = true; } } } }

    Read the article

  • Tools for game script / storyboard

    - by Pietro Polsinelli
    I am searching for a tool that will help in writing a game script. By "script" I mean the text core of a storyboard - without the drawing drafts, which may or may not be there (yet). What I'm thinking of will let write a piece of text of the script, define a simplified workflow from that step, and then define the text of next steps, and so on. Searching online, I found Inform http://inform7.com/ ("A Design System for Interactive Fiction Based on Natural Language") which in theory is exactly what I am searching for, but trying to use it it has this model of a space (a dungeon, a library) where you are picking up objects and exploring them. In my case I am designing more a Sims like game, the flow is entirely different. Considering non specific software, mind mapping tools miss the linearity of the process. What I am writing is a directed graph - simply a work-flow, but the way I want to design it is more text based than work-flow based. SO what I'm doing now is using a text editor, which I'll transform directly in code. Any suggestions?

    Read the article

  • Play animation (storyboard) backwards

    - by drasto
    Is there a simple way to play some StoryBoad backward (reversed) ? As there is a method Storyboard.Begin() I would expect that there is some method like "Storyboard.BeginReversed()" but I cannot find it. If there is no way to play an animation backwards that I have to write for most of my animations complementary animations. That smells bad to me (code duplication of some kind). Basically I just animate a Grid that shows and than hides.

    Read the article

  • WPF Storyboard issue

    - by Vinjamuri
    In the following template, the button is displayed with Normal image when the application is started, but when the mouse is over, the button doesn't get changed to mouse over image. Appreciate your help!!! I want some solution without major changes in the design. <Style TargetType="{x:Type local:ButtonControl}"> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type local:ButtonControl}"> <Grid> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="CommonStates"> <VisualState x:Name="Normal"> <Storyboard> <DoubleAnimation Duration="00:00:00.20" Storyboard.TargetName="imgNormal" Storyboard.TargetProperty="Opacity" To="1" /> </Storyboard> </VisualState> <VisualState x:Name="MouseOver"> <Storyboard> <DoubleAnimation Duration="00:00:00.20" Storyboard.TargetName="imgNormal" Storyboard.TargetProperty="Opacity" To="0" /> <DoubleAnimation Duration="00:00:00.20" Storyboard.TargetName="imgOver" Storyboard.TargetProperty="Opacity" To="1" /> </Storyboard> </VisualState> <VisualState x:Name="Disabled"> <Storyboard> <DoubleAnimation Duration="00:00:00.20" Storyboard.TargetName="imgDisable" Storyboard.TargetProperty="Opacity" To="1" /> </Storyboard> </VisualState> <VisualState x:Name="Pressed"> <Storyboard> <DoubleAnimation Duration="00:00:00.20" Storyboard.TargetName="imgPress" Storyboard.TargetProperty="Opacity" To="1" /> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <Grid> <Border x:Name="imgNormal"> <Image Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=NormalImage}" Opacity="1" Stretch="UniformToFill"/> </Border> </Grid> <Grid> <Border x:Name="imgOver"> <Image Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=MouseOverImage}" Opacity="0" Stretch="UniformToFill"/> </Border> </Grid> <Grid> <Border x:Name="imgDisable"> <Image Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=DisableImage}" Opacity="0" Stretch="UniformToFill"/> </Border> </Grid> <Grid> <Border x:Name="imgPress"> <Image Source="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=MousePressImage}" Opacity="0" Stretch="UniformToFill"/> </Border> </Grid> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style>

    Read the article

  • Export data to Excel from Silverlight/WPF DataGrid

    - by outcoldman
    Data export from DataGrid to Excel is very common task, and it can be solved with different ways, and chosen way depend on kind of app which you are design. If you are developing app for enterprise, and it will be installed on several computes, then you can to advance a claim (system requirements) with which your app will be work for client. Or customer will advance system requirements on which your app should work. In this case you can use COM for export (use infrastructure of Excel or OpenOffice). This approach will give you much more flexibility and give you possibility to use all features of Excel app. About this approach I’ll speak below. Other way – your app is for personal use, it can be installed on any home computer, in this case it is not good to ask user to install MS Office or OpenOffice just for using your app. In this way you can use foreign tools for export, or export to xml/html format which MS Office can read (this approach used by JIRA). But in this case will be more difficult to satisfy user tasks, like create document with landscape rotation and with defined fields for printing. At this article I'll show you how to work with Excel object from .NET 4 and Silverlight 4 with dynamic objects and give you an approach which allow you to export data from DataGrid Silverlight and WPF controls. Read more...

    Read the article

  • WPF Storyboard works well, except for the first time it runs. Why?

    - by sofri
    Hi, I'm doing a Surface Application. And there I have something like a bulletin board where little cards with news on it are pinned on. On click they shall fly out of the board and scale bigger. My storyboard works well, except for the first time it runs. It's not a smooth animation then but it scales to its final size immediately and it's the same with the orientation-property. Just the center-property seems to behave correctly. This is an example for one of my Storyboards doing that: Storyboard stb = new Storyboard(); PointAnimation moveCenter = new PointAnimation(); DoubleAnimationUsingKeyFrames changeWidth = new DoubleAnimationUsingKeyFrames(); DoubleAnimationUsingKeyFrames changeHeight = new DoubleAnimationUsingKeyFrames(); DoubleAnimationUsingKeyFrames changeOrientation = new DoubleAnimationUsingKeyFrames(); moveCenter.From = News1.ActualCenter; moveCenter.To = new Point(250, 400); moveCenter.Duration = new Duration(TimeSpan.FromSeconds(1.0)); moveCenter.FillBehavior = FillBehavior.Stop; stb.Children.Add(moveCenter); Storyboard.SetTarget(moveCenter, News1); Storyboard.SetTargetProperty(moveCenter, new PropertyPath(ScatterViewItem.CenterProperty)); changeWidth.Duration = TimeSpan.FromSeconds(1); changeWidth.KeyFrames.Add(new EasingDoubleKeyFrame(266, KeyTime.FromTimeSpan(new System.TimeSpan(0, 0, 1)))); changeWidth.FillBehavior = FillBehavior.Stop; stb.Children.Add(changeWidth); Storyboard.SetTarget(changeWidth, News1); Storyboard.SetTargetProperty(changeWidth, new PropertyPath(FrameworkElement.WidthProperty)); changeHeight.Duration = TimeSpan.FromSeconds(1); changeHeight.KeyFrames.Add(new EasingDoubleKeyFrame(400, KeyTime.FromTimeSpan(new System.TimeSpan(0, 0, 1)))); changeHeight.FillBehavior = FillBehavior.Stop; stb.Children.Add(changeHeight); Storyboard.SetTarget(changeHeight, News1); Storyboard.SetTargetProperty(changeHeight, new PropertyPath(FrameworkElement.HeightProperty)); changeOrientation.Duration = TimeSpan.FromSeconds(1); changeOrientation.KeyFrames.Add(new EasingDoubleKeyFrame(0, KeyTime.FromTimeSpan(new System.TimeSpan(0, 0, 1)))); changeOrientation.FillBehavior = FillBehavior.Stop; stb.Children.Add(changeOrientation); Storyboard.SetTarget(changeOrientation, News1); Storyboard.SetTargetProperty(changeOrientation, new PropertyPath(ScatterViewItem.OrientationProperty)); stb.Begin(this); News1.Center = new Point(250, 400); News1.Orientation = 0; News1.Width = 266; News1.Height = 400; Pin1.Visibility = Visibility.Collapsed; news1IsOutside = true; Scroll1.IsEnabled = true; What's wrong with it?

    Read the article

  • WPF Login Screen

    - by Asim Sajjad
    I have search on google about the login screens which are design in WPF , as I have to using one of the best login screen for my application, Is the any good login screen avaialble so that I can see them and choose one of them, I am having no idean about the good design of the login screen. Please help me, thanks in advance

    Read the article

  • WPF Dialog Box Property Value Editor access source control

    - by Cicik
    Hello, I have User control in WPF with dependency property DEP1 on which i set value by DialogPropertyValueEditor(code below): Public Class OPCItemDialogPropertyValueEditor Inherits DialogPropertyValueEditor Private res As New EditorResources() Public Sub New() Me.InlineEditorTemplate = TryCast(res("OPCItemInlineEditorTemplate"), DataTemplate) End Sub Public Overrides Sub ShowDialog(ByVal propertyValue As PropertyValue, ByVal commandSource As IInputElement) Dim window As New MyWindowToSetProperty(SomeParameter, "STRING Value Of ANother Property In control") If window.ShowDialog() Then propertyValue.Value = window.ChoosedOPCItem End If End Sub End Class I need to set value of property of my control as parameter("STRING Value Of ANother Property In control") for window from i set value to property DEP1 Thanks

    Read the article

  • WPF Dialog Box Property Value Editor access source(parent) control

    - by Cicik
    Hello, I have User control in WPF with dependency property DEP1 on which i set value by DialogPropertyValueEditor(code below): Public Class OPCItemDialogPropertyValueEditor Inherits DialogPropertyValueEditor Private res As New EditorResources() Public Sub New() Me.InlineEditorTemplate = TryCast(res("OPCItemInlineEditorTemplate"), DataTemplate) End Sub Public Overrides Sub ShowDialog(ByVal propertyValue As PropertyValue, ByVal commandSource As IInputElement) Dim window As New MyWindowToSetProperty(SomeParameter, "STRING Value Of ANother Property In control") If window.ShowDialog() Then propertyValue.Value = window.ChoosedOPCItem End If End Sub End Class I need to set value of property of my control as parameter("STRING Value Of ANother Property In control") for window from i set value to property DEP1 Thanks

    Read the article

  • [WPF] Control focus styling

    - by Prashant
    Hey guys, in above image you would notice that, doted rectangle indicating ComboBox is focused But the problem is it exceeding the text area of ComboBox... how do I align it with text area WPF Style? Thanks

    Read the article

  • WPF DataGrid binding to UserControl

    - by Trindaz
    I have a DataGrid with one column using a UserControl via a styled DataGridTemplateColumn. I can't seem to get the UserControl to 'see' the object that is in it's containing DataGridCell though. What kind of bindings can I create on the TextBox in my UserControl so that it can look up and see that object?! My UserControl and TemplateColumn Style are defined as: <Window.Resources> <local:UCTest x:Key="UCTest" /> <Style x:Key="TestStyle" TargetType="{x:Type WpfToolkit:DataGridCell}"> <Style.Setters> <Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="{x:Type WpfToolkit:DataGridCell}"> <Grid Background="{Binding RelativeSource={RelativeSource TemplatedParent}, Converter={StaticResource drc}, Path=DataContext}"> <Grid.ColumnDefinitions> <ColumnDefinition/> <ColumnDefinition/> </Grid.ColumnDefinitions> <local:UCTest /> </Grid> </ControlTemplate> </Setter.Value> </Setter> </Style.Setters> </Style> </Window.Resources> and my sample DataGrid is defined as: <WpfToolkit:DataGrid Name="dgSampleData" ItemsSource="{Binding}" AutoGenerateColumns="True" Margin="0,75,0,0"> <WpfToolkit:DataGrid.Columns> <WpfToolkit:DataGridTemplateColumn Header="Col2" CellStyle="{StaticResource TestStyle}" /> </WpfToolkit:DataGrid.Columns> </WpfToolkit:DataGrid> and my User Control is defined in a separate file as: <UserControl x:Class="UCTest" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:local="clr-namespace:WpfApplication1" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Width="104" Height="51"> <UserControl.Resources> <local:DataRowConverter x:Key="drc" /> </UserControl.Resources> <Grid> <TextBox Margin="12,12,-155,16" Name="TextBox1" Text="" /> </Grid> EDIT: My implementation of TestClass, which has the Test Property, which I want UCTest.TextBox1 to bind do: Public Class TestClass Private _Test As String = "Hello World Property!" Public Property Test() As String Get Return _Test End Get Set(ByVal value As String) _Test = value End Set End Property End Class Thanks in advance!

    Read the article

  • WPF trigger on datagrid to hide/show columns according to bindings

    - by Renan
    I have a data grid like this: <DataGrid AutoGenerateColumns="False" CanUserDeleteRows="True" HorizontalScrollBarVisibility="Hidden" Margin="10,10,10,10" VerticalScrollBarVisibility="Visible" CanUserAddRows="False" ItemsSource="{Binding ListGestores}" ToolTip="Selecione uma linha e pressione DELETE para remover uma unidade."> <DataGrid.Columns> <DataGridTextColumn Binding="{Binding TB_UNIDADE.DS_NOME_UNIDADE}" CanUserResize="False" Header="Setor" IsReadOnly="True" x:Name=""/> <DataGridTextColumn Binding="{Binding TB_UNIDADE.TB_UNIDADE2.DS_NOME_UNIDADE}" CanUserResize="False" Header="Unidade" IsReadOnly="True" x:Name=""/> <DataGridTextColumn Binding="{Binding TB_CONTATOS.DS_NOME}" CanUserResize="False" Header="Gestor" IsReadOnly="True" /> </DataGrid.Columns> </DataGrid> The problem is that i need to verify if the 2 column binding is null, and if it is null, i need to Hide it, and Change the Header of the column 1. I know that i can do that with Triggers, but how exactly??? I started with: <DataGrid.Triggers> <DataTrigger Binding="{Binding TB_UNIDADE.TB_UNIDADE2}" Value="{x:Null}"> <Setter Property="" Value="" /> </DataTrigger> </DataGrid.Triggers> But i don't know what setter or whatever to put ! Help me =]

    Read the article

  • Binding the position and size of a UserControl inside a Canvas in WPF

    - by John
    Hi. We have dynamically created (i.e. during runtime, via code-behind) UserControls inside a Canvas. We want to bind the position (Canvas.Left and Canvas.Top) and width of those sizable and draggable UserControls to a ObservableCollection<. How would we achieve this if the Usercontrol is contained in a DataTemplate which in turn is used by a ListBox whose DataContext is set to the collection we want to bind to? In other words, how do we bind a control's position and size that doesn't exist in XAML, but in code only (because it's created by clicking and dragging the mouse)? Notice that the collection can be empty or not empty, meaning that the size and position stores in a collection item must be correctly bound to so that the UserControl can be sized and positioned correctly in the Canvas - via DataBinding. Is this possible?

    Read the article

  • How to bind a datatable to a wpf editable combobox: selectedItem showing System.Data.DataRowView

    - by black sensei
    Hello Good People!! I bound a datatable to a combobox and defined a dataTemplate in the itemTemplate.i can see desired values in the combobox dropdown list,what i see in the selectedItem is System.Data.DataRowView here are my codes: <ComboBox Margin="128,139,123,0" Name="cmbEmail" Height="23" VerticalAlignment="Top" TabIndex="1" ToolTip="enter the email you signed up with here" IsEditable="True" IsSynchronizedWithCurrentItem="True" ItemsSource="{Binding}"> <ComboBox.ItemTemplate> <DataTemplate> <StackPanel> <TextBlock Text="{Binding Path=username}"/> </StackPanel> </DataTemplate> </ComboBox.ItemTemplate> The code behind is so : if (con != null) { con.Open(); //users table has columns id | username | pass SQLiteCommand cmd = new SQLiteCommand("select * from users", con); SQLiteDataAdapter da = new SQLiteDataAdapter(cmd); userdt = new DataTable("users"); da.Fill(userdt); cmbEmail.DataContext = userdt; } I've been looking for something like SelectedValueTemplate or SelectedItemTemplate to do the same kind of data templating but i found none. I'll like to ask if i'm doing something wrong or it's a known issue for combobox binding? if something is wrong in my code please point me to the right direction. thanks for reading this

    Read the article

  • WPF Styles and Tooltips Question

    - by A.R.
    I have a style that I am using to make dynamic tooltips on certain text boxes like so. <Style TargetType="{x:Type TextBox}"> <Setter Property="MinWidth" Value="100"/> <Style.Triggers> <Trigger Property="Validation.HasError" Value="True"> <!-- item of interest --> <Setter Property="ToolTip"> <Setter.Value> <MultiBinding Converter="{StaticResource ErrorMessageConverter}"> <Binding RelativeSource="{RelativeSource Self}" Path="Tag"/> </MultiBinding> </Setter.Value> </Setter> </Trigger> </Style.Triggers> </Style> This works very well, but if I want to use a more complex tooltip I can't figure out how to bind to 'Tag' anymore for the converter value. For example; ... <Setter Property="ToolTip"> <Setter.Value> <StackPanel> <TextBlock> <TextBlock.Text> <MultiBinding Converter="{StaticResource ErrorMessageConverter}"> <!-- item of interest --> <Binding RelativeSource=" what goes here?? "/> </MultiBinding> </TextBlock.Text> </TextBlock> <Image/> </StackPanel> </Setter.Value> </Setter> ... I have tried several flavors of 'FindAncestor' and what not for the relative source, but I can't get anything to work. Any ideas?? UPDATE: 12-29-2010 : Here is the correct code, answer provided by our friend Goblin below. Works perfectly! ... <Setter Property="ToolTip"> <Setter.Value> <!-- Item of interest --> <ToolTip DataContext="{Binding Path=PlacementTarget, RelativeSource={x:Static RelativeSource.Self}}"> <StackPanel> <Image/> <TextBlock> <TextBlock.Text> <MultiBinding Converter="{StaticResource ErrorMessageConverter}"> <Binding Path="Tag"/> </MultiBinding> </TextBlock.Text> </TextBlock> </StackPanel> </ToolTip> </Setter.Value> </Setter> ...

    Read the article

  • WPF 4.0 Custom panel won't show dynamically added controls in VS 2010 Designer

    - by Matt Ruwe
    I have a custom panel control that I'm trying to dynamically add controls within. When I run the application the static and dynamically added controls show up perfectly, but the dynamic controls do not appear within the visual studio designer. Only the controls placed declaratively in the XAML appear. I'm currently adding the dynamic control in the CreateUIElementCollection override, but I've also tried this in the constructor without success. Public Class CustomPanel1 Inherits Panel Public Sub New() End Sub Protected Overrides Function MeasureOverride(ByVal availableSize As System.Windows.Size) As System.Windows.Size Dim returnValue As New Size(0, 0) For Each child As UIElement In Children child.Measure(availableSize) returnValue.Width = Math.Max(returnValue.Width, child.DesiredSize.Width) returnValue.Height = Math.Max(returnValue.Height, child.DesiredSize.Height) Next returnValue.Width = If(Double.IsPositiveInfinity(availableSize.Width), returnValue.Width, availableSize.Width) returnValue.Height = If(Double.IsPositiveInfinity(availableSize.Height), returnValue.Height, availableSize.Height) Return returnValue End Function Protected Overrides Function ArrangeOverride(ByVal finalSize As System.Windows.Size) As System.Windows.Size Dim currentHeight As Integer For Each child As UIElement In Children child.Arrange(New Rect(0, currentHeight, child.DesiredSize.Width, child.DesiredSize.Height)) currentHeight += child.DesiredSize.Height Next Return finalSize End Function Protected Overrides Function CreateUIElementCollection(ByVal logicalParent As System.Windows.FrameworkElement) As System.Windows.Controls.UIElementCollection Dim returnValue As UIElementCollection = MyBase.CreateUIElementCollection(logicalParent) returnValue.Add(New TextBlock With {.Text = "Hello, World!"}) Return returnValue End Function Protected Overrides Sub OnPropertyChanged(ByVal e As System.Windows.DependencyPropertyChangedEventArgs) MyBase.OnPropertyChanged(e) End Sub End Class And my usage of this custom panel <Window x:Class="MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:CustomPanel" Title="MainWindow" Height="364" Width="434"> <local:CustomPanel1> <CheckBox /> <RadioButton /> </local:CustomPanel1> </Window>

    Read the article

  • Question on MVVM pattern on WPF ?

    - by Ashish Ashu
    I have a user control let say UC1 . This user control have viewmodel UC1_vm. In the usercontrol UC1 I have a canvas in which drawing curve logic is implemented. This drawing curve logic is based on the data points property in the view model ( UC1_vm). The data points property inside the view model change with different condition. The generation of data points is written in the View Model. I want to bind the data points property in the view model to the draw curve logic inside the User control (view). I want whenever the data point property is changed in the view model , the canvas calls the draw curve method. Can I set the set any property of canvas which when changed it calls the on paint logic auto matically? Please suggest me the approach of implementing this scenario!!

    Read the article

  • DataTrigger to make WPF Button inactive until TextBox has value

    - by JohnB
    I want the Button control's property to be IsEnabled="False" until a value is entered into a TextBox in the Window. Code so far: <Button Content="Click Me" Name="ClickMe" VerticalAlignment="Top" Click="ClickMe_Click"> <Button.Style> <Style> <Style.Triggers> <DataTrigger Binding="{Binding ElementName=textBox, Path=Length}" <!-- or even: Binding="{Binding Path=textBox.Length}" --> Value="0"> <Setter Property="Button.IsEnabled" Value="false" /> </DataTrigger> </Style.Triggers> </Style> </Button.Style> </Button> Also, is it possible to have this Button control's IsEnabled property be based on 3 different TextBox controls all having values?

    Read the article

1 2 3 4 5 6 7 8 9 10 11 12  | Next Page >