Search Results

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

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

  • Books about Advanced WPF control building

    - by Carlo
    Hello. I'm really interested in learning really advanced features of WPF to learn how to create advanced controls, but apparently I'm running out of resources, and possibly, imagination. I have these 4 books: WPF Control Development Unleashed Experiences Pro WPF 2008 Presentation Professionals Programming WPF Chris Sells WPF in Action Visual Studio 2008 One finished, two other half way, the other one just started. I sort of expected more from the "WPF Control Development Unleashed" one. Anyway, do you know any more books about advanced WPF features, and control building? Or even about how WPF works internally. Let me know what are your favorite WPF books, maybe I've overlooked some of them. Thanks!

    Read the article

  • EventTrigger RoutedEvent in wpf xaml

    - by Cinaird
    I have a problem in wpf xaml and i'm pretty new on this so it may be something basic i want to rotate a ellipse 360 degree <Ellipse Name="test" Fill="Black" StrokeThickness="5" Margin="0,0,0,0" Height="66"> <Ellipse.Triggers> <EventTrigger RoutedEvent="Ellipse.Loaded" SourceName="test"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetName="test" Storyboard.TargetProperty="(Ellipse.RenderTransform).(RotateTransform.Angle)" From="0" To="360" Duration="0:0:0.5" RepeatBehavior="1x" /> </Storyboard> </BeginStoryboard> </EventTrigger> </Ellipse.Triggers> </Ellipse> But nothing happens, what is wrong?

    Read the article

  • Wait for all WPF animations to stop

    - by Ray
    Given a WPF window, which may or may not have animations, I'd like to wait until they are all done before continuing processing. Is there a generic way to do this. Currently I can do something like this: void WaitForAnimation(Storyboard storyboard) { WaitUntil(() => storyboard.GetCurrentState() == ClockState.Stopped); } But this assumes I know the storyboards or have some way of finding them. Is there a way of doing that?

    Read the article

  • Manipulating a Storyboard's target object

    - by slugster
    In the handler for the Completed event of a Storyboard, how do i get the element that the storyboard was being applied to? My Storyboard is part of an ItemTemplate: <ListBox x:Name="MyListBox" > <ListBox.ItemTemplate> <DataTemplate> <Grid x:Name="Container" Height="30" > <Grid.Resources> <Storyboard x:Name="FadeOut" BeginTime="0:0:7" Completed="FadeOut_Completed"> <DoubleAnimation From="1.0" To="0.0" Duration="0:0:3" Storyboard.TargetName="Container" Storyboard.TargetProperty="Opacity" /> </Storyboard> </Grid.Resources> [...snip...] </Grid> </DataTemplate> </ListBox.ItemTemplate> </ListBox> in the Completed event i want to grab the grid called Container so that i can do nasty things with its DataContext. Can this be done, or am i going about it the wrong way? Thanks :)

    Read the article

  • Load view when button is clicked in Xcodes Storyboard

    - by dooonot
    I just started to use Storyboard in Xcode. I have a starting view that has some buttons inside. Is there a way to load a special view when a button is clicked? I only found this workaround: -(IBAction)loadRegistration:(id)sender { // load registration controller UIStoryboard *storyboard = self.storyboard; RegisterController *svc = [storyboard instantiateViewControllerWithIdentifier:@"RegisterController"]; [self presentViewController:svc animated:YES completion:nil]; }

    Read the article

  • Windows Presentation Foundation 4.5 Cookbook Review

    - by Ricardo Peres
    As promised, here’s my review of Windows Presentation Foundation 4.5 Cookbook, that Packt Publishing kindly made available to me. It is an introductory book, targeted at WPF newcomers or users with few experience, following the typical recipes or cookbook style. Like all Packt Publishing books on development, each recipe comes with sample code that is self-sufficient for understanding the concepts it tries to illustrate. It starts on chapter 1 by introducing the most important concepts, the XAML language itself, what can be declared in XAML and how to do it, what are dependency and attached properties as well as markup extensions and events, which should give readers a most required introduction to how WPF works and how to do basic stuff. It moves on to resources on chapter 2, which also makes since, since it’s such an important concept in WPF. Next, chapter 3, come the panels used for laying controls on the screen, all of the out of the box panels are described with typical use cases. Controls come next in chapter 4; the difference between elements and controls is introduced, as well as content controls, headered controls and items controls, and all standard controls are introduced. The book shows how to change the way they look by using templates. The next chapter, 5, talks about top level windows and the WPF application object: how to access startup arguments, how to set the main window, using standard dialogs and there’s even a sample on how to have a irregularly-shaped window. This is one of the most important concepts in WPF: data binding, which is the theme for the following chapter, 6. All common scenarios are introduced, the binding modes, directions, triggers, etc. It talks about the INotifyPropertyChanged interface and how to use it for notifying data binding subscribers of changes in data sources. Data templates and selectors are also covered, as are value converters and data triggers. Examples include master-detail and sorting, grouping and filtering collections and binding trees and grids. Last it covers validation rules and error templates. Chapter 7 talks about the current trend in WPF development, the Model View View-Model (MVVM) framework. This is a well known pattern for connecting things interface to actions, and it is explained competently. A typical implementation is presented which also presents the command pattern used throughout WPF. A complete application using MVVM is presented from start to finish, including typical features such as undo. Style and layout is covered on chapter 8. Why/how to use styles, applying them automatically,  using the many types of triggers to change styles automatically, using Expression Blend behaviors and templates are all covered. Next chapter, 9, is about graphics and animations programming. It explains how to create shapes, transform common UI elements, apply special effects and perform simple animations. The following chapter, 10, is about creating custom controls, either by deriving from UserControl or from an existing control or framework element class, applying custom templates for changing the way the control looks. One useful example is a custom layout panel that arranges its children along a circumference. The final chapter, 11, is about multi-threading programming and how one can integrate it with WPF. Includes how to invoke methods and properties on WPF classes from threads other than the main UI, using background tasks and timers and even using the new C# 5.0 asynchronous operations. It’s an interesting book, like I said, mostly for newcomers. It provides a competent introduction to WPF, with examples that cover the most common scenarios and also give directions to more complex ones. I recommend it to everyone wishing to learn WPF.

    Read the article

  • How do I animate UserControl objects using Storyboard and DoubleAnimation?

    - by Neo
    In my WPF application, I have a Canvas object that contains some UserControl objects. I wish to animate the UserControl objects within the Canvas using DoubleAnimation so that they go from the right of the Canvas to the left of the Canvas. This is how I have done it so far (by passing the UserControl objects into the function): private void Animate(FrameworkElement e) { DoubleAnimation ani = new DoubleAnimation() { From = _container.ActualWidth, To = 0.0, Duration = new Duration(new TimeSpan(0, 0, 10), TargetElement = e }; TranslateTransform trans = new TranslateTransform(); e.RenderTransform = trans; trans.BeginAnimation(TranslateTransform.XProperty, ani, HandoffBehavior.Compose); } However, this doesn't allow me to pause the animation, so I have considered using a Storyboard instead to do this, but I'm not sure how to implement this. This has been my attempt so far: private void Animate(FrameworkElement e) { DoubleAnimation ani = new DoubleAnimation() { From = _container.ActualWidth, To = 0.0, Duration = new Duration(new TimeSpan(0, 0, 10), TargetElement = e }; Storyboard stb = new Storyboard(); Storyboard.SetTarget(ani, e); Storyboard.SetTargetProperty(ani, "Left"); stb.Children.Add(ani); stb.Begin(); } Of course, this fails as UserControl doesn't have a Left property. How can I achieve what I'm after? Thanks.

    Read the article

  • Setting a Visual State from a data bound enum in WPF

    - by firoso
    Hey all, I've got a scenario where I want to switch the visiblity of 4 different content controls. The visual states I have set opacity, and collapsed based on each given state (See code.) What I'd like to do is have the visual state bound to a property of my View Model of type Enum. I tried using DataStateBehavior, but it requires true/false, which doesn't work for me. So I tried DataStateSwitchBehavior, which seems to be totally broken for WPF4 from what I could tell. Is there a better way to be doing this? I'm really open to different approaches if need be, but I'd really like to keep this enum in the equation. Edit: The code shouldn't be too important, I just need to know if there's a well known solution to this problem. <UserControl xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:Custom="http://schemas.microsoft.com/expression/2010/interactivity" xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions" xmlns:ee="http://schemas.microsoft.com/expression/2010/effects" xmlns:customBehaviors="clr-namespace:SEL.MfgTestDev.ESS.Behaviors" x:Class="SEL.MfgTestDev.ESS.View.PresenterControl" mc:Ignorable="d" d:DesignHeight="624" d:DesignWidth="1104" d:DataContext="{Binding ApplicationViewModel, Mode=OneWay, Source={StaticResource Locator}}"> <Grid> <Grid.Resources> <ResourceDictionary> <ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="Layout/TerminalViewTemplate.xaml"/> <ResourceDictionary Source="Layout/DebugViewTemplate.xaml"/> <ResourceDictionary Source="Layout/ProgressViewTemplate.xaml"/> <ResourceDictionary Source="Layout/LoadoutViewTemplate.xaml"/> </ResourceDictionary.MergedDictionaries> </ResourceDictionary> </Grid.Resources> <Custom:Interaction.Behaviors> <customBehaviors:DataStateSwitchBehavior Binding="{Binding ApplicationViewState}"> <customBehaviors:DataStateSwitchCase State="LoadoutState" Value="Loadout"/> </customBehaviors:DataStateSwitchBehavior> </Custom:Interaction.Behaviors> <VisualStateManager.VisualStateGroups> <VisualStateGroup x:Name="ApplicationStates" ei:ExtendedVisualStateManager.UseFluidLayout="True"> <VisualStateGroup.Transitions> <VisualTransition GeneratedDuration="0:0:1"> <VisualTransition.GeneratedEasingFunction> <SineEase EasingMode="EaseInOut"/> </VisualTransition.GeneratedEasingFunction> <ei:ExtendedVisualStateManager.TransitionEffect> <ee:SmoothSwirlGridTransitionEffect/> </ei:ExtendedVisualStateManager.TransitionEffect> </VisualTransition> </VisualStateGroup.Transitions> <VisualState x:Name="LoadoutState"> <Storyboard> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="LoadoutPage"> <EasingDoubleKeyFrame KeyTime="0" Value="1"/> </DoubleAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="LoadoutPage"> <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="ProgressState"> <Storyboard> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="ProgressPage"> <EasingDoubleKeyFrame KeyTime="0" Value="1"/> </DoubleAnimationUsingKeyFrames> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="ProgressPage"> <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/> </ObjectAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="DebugState"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="DebugPage"> <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/> </ObjectAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="DebugPage"> <EasingDoubleKeyFrame KeyTime="0" Value="1"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </VisualState> <VisualState x:Name="TerminalState"> <Storyboard> <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="TerminalPage"> <DiscreteObjectKeyFrame KeyTime="0" Value="{x:Static Visibility.Visible}"/> </ObjectAnimationUsingKeyFrames> <DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Opacity)" Storyboard.TargetName="TerminalPage"> <EasingDoubleKeyFrame KeyTime="0" Value="1"/> </DoubleAnimationUsingKeyFrames> </Storyboard> </VisualState> </VisualStateGroup> </VisualStateManager.VisualStateGroups> <ContentControl x:Name="LoadoutPage" ContentTemplate="{StaticResource LoadoutViewTemplate}" Opacity="0" Content="{Binding}" Visibility="Collapsed"/> <ContentControl x:Name="ProgressPage" ContentTemplate="{StaticResource ProgressViewTemplate}" Opacity="0" Content="{Binding}" Visibility="Collapsed"/> <ContentControl x:Name="DebugPage" ContentTemplate="{StaticResource DebugViewTemplate}" Opacity="0" Content="{Binding}" Visibility="Collapsed"/> <ContentControl x:Name="TerminalPage" ContentTemplate="{StaticResource TerminalViewTemplate}" Opacity="0" Content="{Binding}" Visibility="Collapsed"/> <TextBlock HorizontalAlignment="Left" TextWrapping="Wrap" VerticalAlignment="Top" Text="{Binding ApplicationViewState}"> <TextBlock.Background> <LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0"> <GradientStop Color="Black" Offset="0"/> <GradientStop Color="White" Offset="1"/> </LinearGradientBrush> </TextBlock.Background> </TextBlock> </Grid>

    Read the article

  • How apply a storyboard to a Label programmatically ?

    - by ThitoO
    Hi :), I've a little problem, I'd search google and my Wpf's books but I don't found any answer :( I have created a little storyboard : <Storyboard x:Key="whiteAnim" Duration="1"> <ColorAnimation By="Black" To="White" Storyboard.TargetProperty="Background" x:Name="step1"/> <ColorAnimation By="White" To="Black" Storyboard.TargetProperty="Background" x:Name="step2"/> </Storyboard> This animation will change background color from black to white, and from white to black. I want to "apply" this storyboard to a Label : Label label = new Label(); label.Content = "My label"; I'm looking for a method like "label.StartStoryboard(--myStoryboard--), do you have any ideas ? Thank you :)

    Read the article

  • Animate button on MouseOver and MouseDown

    - by haagel
    I'm making my own ControlTemplate for a standard Button in WPF. I want to change the background of my button when the user hovers over the button with the mouse, but also when the user presses the button (to yet another color). This seems like a common behavior, but I can't get it to work. My template consists of a Border with an Image inside. It is the background color (a gradient really) of the Border that I want to animate. I have triggers in my template that activates animations (storyboards). The MouseOver/Out works just fine. My problem occurs when I press the button. The Press animation runs as it should, and so does the Release animation. But after this the MouseOut will never run. The button gets stuck in the MouseOver state. What am I doing wrong? <ControlTemplate TargetType="{x:Type Button}"> <ControlTemplate.Resources> <Storyboard x:Key="MouseOverAnimation"> <ColorAnimation Storyboard.TargetName="ButtonBorderGradientStop1" Storyboard.TargetProperty="Color" To="#ffefefff" Duration="0:0:0.2" /> <ColorAnimation Storyboard.TargetName="ButtonBorderGradientStop2" Storyboard.TargetProperty="Color" To="#ffc7c7ff" Duration="0:0:0.2" /> </Storyboard> <Storyboard x:Key="MouseOutAnimation"> <ColorAnimation Storyboard.TargetName="ButtonBorderGradientStop1" Storyboard.TargetProperty="Color" To="#ffeeeeee" Duration="0:0:0.2" /> <ColorAnimation Storyboard.TargetName="ButtonBorderGradientStop2" Storyboard.TargetProperty="Color" To="#ffcccccc" Duration="0:0:0.2" /> </Storyboard> <Storyboard x:Key="MouseDownAnimation"> <ColorAnimation Storyboard.TargetName="ButtonBorderGradientStop1" Storyboard.TargetProperty="Color" To="#ffc7c7ff" Duration="0:0:0.1" /> <ColorAnimation Storyboard.TargetName="ButtonBorderGradientStop2" Storyboard.TargetProperty="Color" To="#ff9a9aff" Duration="0:0:0.1" /> </Storyboard> <Storyboard x:Key="MouseUpAnimation"> <ColorAnimation Storyboard.TargetName="ButtonBorderGradientStop1" Storyboard.TargetProperty="Color" To="#ffefefff" Duration="0:0:0.1" /> <ColorAnimation Storyboard.TargetName="ButtonBorderGradientStop2" Storyboard.TargetProperty="Color" To="#ffc7c7ff" Duration="0:0:0.1" /> </Storyboard> </ControlTemplate.Resources> <Border x:Name="ButtonBorder" CornerRadius="0" BorderBrush="#55aaaaaa" BorderThickness="1" Width="23" Height="22"> <Border.Background> <LinearGradientBrush StartPoint="0,0" EndPoint="0,1"> <GradientBrush.GradientStops> <GradientStop x:Name="ButtonBorderGradientStop1" Color="#ffeeeeee" Offset="0.0" /> <GradientStop x:Name="ButtonBorderGradientStop2" Color="#ffcccccc" Offset="1.0" /> </GradientBrush.GradientStops> </LinearGradientBrush> </Border.Background> <Image x:Name="ButtonIcon" Source="icons/searchicon_bw.png" Width="16" Height="16" /> </Border> <ControlTemplate.Triggers> <Trigger Property="IsMouseOver" Value="True"> <Trigger.EnterActions> <BeginStoryboard Storyboard="{StaticResource MouseOverAnimation}" /> </Trigger.EnterActions> <Trigger.ExitActions> <BeginStoryboard Storyboard="{StaticResource MouseOutAnimation}" /> </Trigger.ExitActions> </Trigger> <Trigger Property="IsPressed" Value="True"> <Trigger.EnterActions> <BeginStoryboard Storyboard="{StaticResource MouseDownAnimation}" /> </Trigger.EnterActions> <Trigger.ExitActions> <BeginStoryboard Storyboard="{StaticResource MouseUpAnimation}" /> </Trigger.ExitActions> </Trigger> </ControlTemplate.Triggers> </ControlTemplate>

    Read the article

  • DoubleAnimation in ScaleTransform

    - by Adam S
    I'm trying, as an exhibition, to use a DoubleAnimation on the ScaleX and ScaleY properties of a ScaleTransform. I have a rectangle (144x144) which I want to make rectangular over five seconds. My XAML: <Window x:Class="ScaleTransformTest.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" Loaded="Window_Loaded"> <Grid> <Rectangle Name="rect1" Width="144" Height="144" Fill="Aqua"> <Rectangle.RenderTransform> <ScaleTransform ScaleX="1" ScaleY="1" /> </Rectangle.RenderTransform> </Rectangle> </Grid> </Window> My C#: private void Window_Loaded(object sender, RoutedEventArgs e) { ScaleTransform scaly = new ScaleTransform(1, 1); rect1.RenderTransform = scaly; Duration mytime = new Duration(TimeSpan.FromSeconds(5)); Storyboard sb = new Storyboard(); DoubleAnimation danim1 = new DoubleAnimation(1, 1.5, mytime); DoubleAnimation danim2 = new DoubleAnimation(1, 0.5, mytime); sb.Children.Add(danim1); sb.Children.Add(danim2); Storyboard.SetTarget(danim1, scaly); Storyboard.SetTargetProperty(danim1, new PropertyPath(ScaleTransform.ScaleXProperty)); Storyboard.SetTarget(danim2, scaly); Storyboard.SetTargetProperty(danim2, new PropertyPath(ScaleTransform.ScaleYProperty)); sb.Begin(); } Unfortunately, when I run this program, it does nothing. The rectangle stays at 144x144. If I do away with the animation, and just ScaleTransform scaly = new ScaleTransform(1.5, 0.5); rect1.RenderTransform = scaly; it will elongate it instantly, no problem. There is a problem elsewhere. Any suggestions? I have read the discussion at http://www.eggheadcafe.com/software/aspnet/29220878/how-to-animate-tofrom-an.aspx in which someone seems to have gotten a pure-XAML version working, but the code is not shown there. EDIT: At http://stackoverflow.com/questions/2131797/applying-animated-scaletransform-in-code-problem it seems someone had a very similar problem, I am fine with using his method that worked, but what the heck is that string thePath = "(0).(1)[0].(2)"; all about? What are those numbers representing?

    Read the article

  • Storyboard elements are not sized properly on the device

    - by Joel Fischer
    In the storyboard, I am placing a table view element into a subclassed UIView. The element is not appearing on the iPad device I am running it on the same as it appears in the storyboard however. This also happens for additional content that I place into the storyboard. Below is a screenshot as it appears in the storyboard, as well as UI width/height information. And here is the description of the UI file running on the iPad. https://gist.github.com/4323186 (embedding it directly into the post is giving me problems) You'll notice that the tableview is explicitly set at 178 width, and is showing up in the description as 276 width. My initial thought was that perhaps a cell was forcing the parent to be larger (I'm very new to iOS UI development), but drilling into that shows the prototype cell it appears that the width is defined by it's parent at 178. The image views and label also are appearing in the incorrect spot, as shown in the second image below.

    Read the article

  • Apply Storyboard Animation to DataGridTemplateColumn depending on Binding value change

    - by Neo
    I have a DataGridTemplateColumn on a WPF DataGrid which has a binding to a double type. I wish to apply a Storyboard Animation when the value goes down and another Storyboard Animation when the value goes up. I've got the following code to start with: <dg:DataGridTemplateColumn Header="My Double"> <dg:DataGridTemplateColumn.CellTemplate> <DataTemplate> <TextBlock Text="{Binding Path=MyDouble, NotifyOnTargetUpdated=True}" TargetUpdated="dgRates_TargetUpdated"> <TextBlock.Triggers> <EventTrigger RoutedEvent="Binding.TargetUpdated"> <BeginStoryboard> <Storyboard> <DoubleAnimation Storyboard.TargetProperty="Opacity" Duration="0:0:2" From="1.0" To="0.0" /> </Storyboard> </BeginStoryboard> </EventTrigger> </TextBlock.Triggers> </TextBlock> </DataTemplate> </dg:DataGridTemplateColumn.CellTemplate> </dg:DataGridTemplateColumn> How can I achieve this? Thanks.

    Read the article

  • Working on WPF application Memory Profiling

    - by akjoshi
    Today, I am going to start with the task of memory profiling the WPF application, on which I am working from past few months. I have successfully done this in past, fixing a lot of memory leaks and improving the performance of WPF applications; As in past, I am hopeful of fixing some very interesting bugs and improve the application performance. I am very excited as current application is very different from the previous WPF applications I had profiled, all the previous application were pure WPF...(read more)

    Read the article

  • New to iPhone Development - iOS5 Storyboard

    - by Peter
    I'm new here and pretty new to iOS development. My question is basically, should I learn the old school development methods or just learn how to do things using the latest tools (i.e. Storyboard)? I've had a go with the Storyboard feature of XCode 4.2 and it's very powerful. My only concern is that it requires iOS 5. I don't mind learning the old way of doing things but I've been having trouble finding tutorials/examples for XCode 4.2 that don't use the storyboard. An example would be the with my trouble finding a good tutorial on how to embed a Navigation Controller into a TabBarController. A lot of the material out there seems to be for older version of XCode. Using the storyboard I'm able to set this up with seconds but still haven't managed to get it working without it. So in short :) would you guys suggest I continue my project using the Storyboard or make the extra effort to do things a little more manually?

    Read the article

  • Moving from Winforms to WPF

    - by Elmex
    I am a long time experienced Windows Forms developer, but now it's time to move to WPF because a new WPF project is comming soon to me and I have only a short lead time to prepare myself to learn WPF. What is the best way for a experienced Winforms devleoper? Can you give me some hints and recommendations to learn WPF in a very short time! Are there simple sample WPF solutions and short (video) tutorials? Which books do you recommend? Is www.windowsclient.net a good starting point? Are there alternatives to the official Microsoft site? Thanks in advance for your help!

    Read the article

  • Moving from Winforms to WPF

    - by Elmex
    I am a long time experienced Windows Forms developer, but now it's time to move to WPF because a new WPF project is comming soon to me and I have only a short lead time to prepare myself to learn WPF. What is the best way for a experienced Winforms devleoper? Can you give me some hints and recommendations to learn WPF in a very short time! Are there simple sample WPF solutions and short (video) tutorials? Which books do you recommend? Is www.windowsclient.net a good starting point? Are there alternatives to the official Microsoft site? Thanks in advance for your help!

    Read the article

  • A WPF Image Button

    - by psheriff
    Instead of a normal button with words, sometimes you want a button that is just graphical. Yes, you can put an Image control in the Content of a normal Button control, but you still have the button outline, and trying to change the style can be rather difficult. Instead I like creating a user control that simulates a button, but just accepts an image. Figure 1 shows an example of three of these custom user controls to represent minimize, maximize and close buttons for a borderless window. Notice the highlighted image button has a gray rectangle around it. You will learn how to highlight using the VisualStateManager in this blog post.Figure 1: Creating a custom user control for things like image buttons gives you complete control over the look and feel.I would suggest you read my previous blog post on creating a custom Button user control as that is a good primer for what I am going to expand upon in this blog post. You can find this blog post at http://weblogs.asp.net/psheriff/archive/2012/08/10/create-your-own-wpf-button-user-controls.aspx.The User ControlThe XAML for this image button user control contains just a few controls, plus a Visual State Manager. The basic outline of the user control is shown below:<Border Grid.Row="0"        Name="borMain"        Style="{StaticResource pdsaButtonImageBorderStyle}"        MouseEnter="borMain_MouseEnter"        MouseLeave="borMain_MouseLeave"        MouseLeftButtonDown="borMain_MouseLeftButtonDown">  <VisualStateManager.VisualStateGroups>  ... MORE XAML HERE ...  </VisualStateManager.VisualStateGroups>  <Image Style="{StaticResource pdsaButtonImageImageStyle}"         Visibility="{Binding Path=Visibility}"         Source="{Binding Path=ImageUri}"         ToolTip="{Binding Path=ToolTip}" /></Border>There is a Border control named borMain and a single Image control in this user control. That is all that is needed to display the buttons shown in Figure 1. The definition for this user control is in a DLL named PDSA.WPF. The Style definitions for both the Border and the Image controls are contained in a resource dictionary names PDSAButtonStyles.xaml. Using a resource dictionary allows you to create a few different resource dictionaries, each with a different theme for the buttons.The Visual State ManagerTo display the highlight around the button as your mouse moves over the control, you will need to add a Visual State Manager group. Two different states are needed; MouseEnter and MouseLeave. In the MouseEnter you create a ColorAnimation to modify the BorderBrush color of the Border control. You specify the color to animate as “DarkGray”. You set the duration to less than a second. The TargetName of this storyboard is the name of the Border control “borMain” and since we are specifying a single color, you need to set the TargetProperty to “BorderBrush.Color”. You do not need any storyboard for the MouseLeave state. Leaving this VisualState empty tells the Visual State Manager to put everything back the way it was before the MouseEnter event.<VisualStateManager.VisualStateGroups>  <VisualStateGroup Name="MouseStates">    <VisualState Name="MouseEnter">      <Storyboard>        <ColorAnimation             To="DarkGray"            Duration="0:0:00.1"            Storyboard.TargetName="borMain"            Storyboard.TargetProperty="BorderBrush.Color" />      </Storyboard>    </VisualState>    <VisualState Name="MouseLeave" />  </VisualStateGroup></VisualStateManager.VisualStateGroups>Writing the Mouse EventsTo trigger the Visual State Manager to run its storyboard in response to the specified event, you need to respond to the MouseEnter event on the Border control. In the code behind for this event call the GoToElementState() method of the VisualStateManager class exposed by the user control. To this method you will pass in the target element (“borMain”) and the state (“MouseEnter”). The VisualStateManager will then run the storyboard contained within the defined state in the XAML.private void borMain_MouseEnter(object sender,  MouseEventArgs e){  VisualStateManager.GoToElementState(borMain,    "MouseEnter", true);}You also need to respond to the MouseLeave event. In this event you call the VisualStateManager as well, but specify “MouseLeave” as the state to go to.private void borMain_MouseLeave(object sender, MouseEventArgs e){  VisualStateManager.GoToElementState(borMain,     "MouseLeave", true);}The Resource DictionaryBelow is the definition of the PDSAButtonStyles.xaml resource dictionary file contained in the PDSA.WPF DLL. This dictionary can be used as the default look and feel for any image button control you add to a window. <ResourceDictionary  ... >  <!-- ************************* -->  <!-- ** Image Button Styles ** -->  <!-- ************************* -->  <!-- Image/Text Button Border -->  <Style TargetType="Border"         x:Key="pdsaButtonImageBorderStyle">    <Setter Property="Margin"            Value="4" />    <Setter Property="Padding"            Value="2" />    <Setter Property="BorderBrush"            Value="Transparent" />    <Setter Property="BorderThickness"            Value="1" />    <Setter Property="VerticalAlignment"            Value="Top" />    <Setter Property="HorizontalAlignment"            Value="Left" />    <Setter Property="Background"            Value="Transparent" />  </Style>  <!-- Image Button -->  <Style TargetType="Image"         x:Key="pdsaButtonImageImageStyle">    <Setter Property="Width"            Value="40" />    <Setter Property="Margin"            Value="6" />    <Setter Property="VerticalAlignment"            Value="Top" />    <Setter Property="HorizontalAlignment"            Value="Left" />  </Style></ResourceDictionary>Using the Button ControlOnce you make a reference to the PDSA.WPF DLL from your WPF application you will see the “PDSAucButtonImage” control appear in your Toolbox. Drag and drop the button onto a Window or User Control in your application. I have not referenced the PDSAButtonStyles.xaml file within the control itself so you do need to add a reference to this resource dictionary somewhere in your application such as in the App.xaml.<Application.Resources>  <ResourceDictionary>    <ResourceDictionary.MergedDictionaries>      <ResourceDictionary         Source="/PDSA.WPF;component/PDSAButtonStyles.xaml" />    </ResourceDictionary.MergedDictionaries>  </ResourceDictionary></Application.Resources>This will give your buttons a default look and feel unless you override that dictionary on a specific Window or User Control or on an individual button. After you have given a global style to your application and you drag your image button onto a window, the following will appear in your XAML window.<my:PDSAucButtonImage ... />There will be some other attributes set on the above XAML, but you simply need to set the x:Name, the ToolTip and ImageUri properties. You will also want to respond to the Click event procedure in order to associate an action with clicking on this button. In the sample code you download for this blog post you will find the declaration of the Minimize button to be the following:<my:PDSAucButtonImage       x:Name="btnMinimize"       Click="btnMinimize_Click"       ToolTip="Minimize Application"       ImageUri="/PDSA.WPF;component/Images/Minus.png" />The ImageUri property is a dependency property in the PDSAucButtonImage user control. The x:Name and the ToolTip we get for free. You have to create the Click event procedure yourself. This is also created in the PDSAucButtonImage user control as follows:private void borMain_MouseLeftButtonDown(object sender,  MouseButtonEventArgs e){  RaiseClick(e);}public delegate void ClickEventHandler(object sender,  RoutedEventArgs e);public event ClickEventHandler Click;protected void RaiseClick(RoutedEventArgs e){  if (null != Click)    Click(this, e);}Since a Border control does not have a Click event you will create one by using the MouseLeftButtonDown on the border to fire an event you create called “Click”.SummaryCreating your own image button control can be done in a variety of ways. In this blog post I showed you how to create a custom user control and simulate a button using a Border and Image control. With just a little bit of code to respond to the MouseLeftButtonDown event on the border you can raise your own Click event. Dependency properties, such as ImageUri, allow you to set attributes on your custom user control. Feel free to expand on this button by adding additional dependency properties, change the resource dictionary, and even the animation to make this button look and act like you want.NOTE: You can download the sample code for this article by visiting my website at http://www.pdsa.com/downloads. Select “Tips & Tricks”, then select “A WPF Image  Button” from the drop down list.

    Read the article

  • Is it possible for a WPF control to have an ActualWidth and ActualHeight if it has never been render

    - by DanM
    I need a Viewport3D for the sole purpose of doing geometric calculations using Petzold.Media3D.ViewportInfo. I do now want to place it in a Window. I'm creating a Viewport3D using the following code: private Viewport3D CreateViewport(MainSettings settings) { var cameraPosition = new Point3D(0, 0, settings.CameraHeight); var cameraLookDirection = new Vector3D(0, 0, -1); var cameraUpDirection = new Vector3D(0, 1, 0); var camera = new PerspectiveCamera { Position = cameraPosition, LookDirection = cameraLookDirection, UpDirection = cameraUpDirection }; var viewport = new Viewport3D { Camera = camera, Width = settings.ViewportWidth, Height = settings.ViewportHeight }; return viewport; } Later, I'm attempting to use this viewport to convert the mouse location to a 3D location using this method: public Point3D? Point2dToPoint3d(Point point) { var range = new LineRange(); var isValid = ViewportInfo.Point2DtoPoint3D(_viewport, point, out range); if (isValid) return range.PointFromZ(0); else return null; } Unfortunately, it's not working. I think the reason is that the ActualWidth and ActualHeight of the viewport and both zero (and these are read-only properties, so I can't set them manually). (I have tested the exact same with an actual rendered Viewport3D, so I know the issue is not with my converter method.) Any idea how I can get WPF to assign the ActualWidth and ActualHeight based on my Width and Height settings? I tried setting the HorizontalAlignment and VerticalAlignment to Left and Top, respectively, and I also messed with the MinWidth and MinHeight, but none of these properties had any effect on the ActualWidth or ActualHeight.

    Read the article

  • Reducing WPF binding boilerplate with styles - updating the bindings themselves via styling?

    - by Eamon Nerbonne
    I'm still learning the WPF ropes, so if the following question is trivial or my approach wrong-headed, please do speak up... I'm trying to reduce boilerplate and it sounds like styles are a common way to do so. In particular: I've got a bunch of fairly mundane data-entry fields. The controls for these fields have various properties I'd like to set based on the target of the binding - pretty normal stuff. However, I'd also like to set properties of the binding itself in the style to avoid repetitiveness. For example: <TextBox Style="{StaticResource myStyle}"> <TextBox.Text> <Binding Path="..." Source="..." ValidatesOnDataErrors="True" ValidatesOnExceptions="True" UpdateSourceTrigger="PropertyChanged"> </Binding> </TextBox.Text> </TextBox> Now, is there any way to use styling - or some other technique to write the previous example somewhat like this: <TextBox Style="{StaticResource myStyle}" Text="{Binding Source=... Path=...}/> That is, is there any way to set all bindings that match a particular selection (here, on controls with the myStyle style) to validate data and to use a particular update trigger? Is it possible to template or style bindings themselves? Clearly, the second syntax is much, much shorter and more readable, and I'd love to be able to get rid of other similar boilerplate to keep my UI code comprehensible to myself :-).

    Read the article

  • WPF: Is it possible to add or modify bindings via styles or something similar?

    - by Eamon Nerbonne
    I'm still learning the WPF ropes, so if the following question is trivial or my approach wrong-headed, please do speak up... I'm trying to reduce boilerplate and it sounds like styles are a common way to do so. In particular: I've got a bunch of fairly mundane data-entry fields. The controls for these fields have various properties I'd like to set based on the target of the binding - pretty normal stuff. However, I'd also like to set properties of the binding itself in the style to avoid repetitiveness. For example: <TextBox Style="{StaticResource myStyle}"> <TextBox.Text> <Binding Path="..." Source="..." ValidatesOnDataErrors="True" ValidatesOnExceptions="True" UpdateSourceTrigger="PropertyChanged"> </Binding> </TextBox.Text> </TextBox> Now, is there any way to use styling - or some other technique to write the previous example somewhat like this: <TextBox Style="{StaticResource myStyle}" Text="{Binding Source=... Path=...}/> That is, is there any way to set all bindings that match a particular selection (here, on controls with the myStyle style) to validate data and to use a particular update trigger? Is it possible to template or style bindings themselves? Alternatively, is it possible to add the binding in the style itself? Clearly, the second syntax is much, much shorter and more readable, and I'd love to be able to get rid of other similar boilerplate to keep my UI code comprehensible to myself :-).

    Read the article

  • WPF Layout algorithm woes - control will resize, but not below some arbitrary value.

    - by Quantumplation
    I'm working on an application for a client, and one of the requirements is the ability to make appointments, and display the current week's appointments in a visual format, much like in Google Calender's or Microsoft Office. I found a great (3 part) article on codeproject, in which he builds a "RangePanel", and composes one for each "period" (for example, the work day.) You can find part 1 here: http://www.codeproject.com/KB/WPF/OutlookWpfCalendarPart1.aspx The code presents, but seems to choose an arbitrary height value overall (440.04), and won't resize below that without clipping. What I mean to say, is that the window/container will resize, but it just cuts off the bottom of the control, instead of recalculating the height of the range panels, and the controls in the range panels representing the appointment. It will resize and recalculate for greater values, but not less. Code-wise, what's happening is that when you resize below that value, first the "MeasureOverride" is called with the correct "new height". However, by the time the "ArrangeOverride" method is called, it's passing the same 440.04 value as the height to arrange to. I need to find a solution/workaround, but any information that you can provide that might direct me for things to look into would also be greatly appreciated ( I understand how frustrating it is to debug code when you don't have the codebase in front of you. :) ) The code for the various Arrange and Measure functions are provided below. The "CalendarView" control has a "CalendarViewContentPresenter", which handles several periods. Then, the periods have a "CalendarPeriodContentPresenter", which handles each "block" of appointments. Finally, the "RangePanel" has it's own implementation. (To be honest, i'm still a bit hazy on how the control works, so if my explanations are a bit hazy, the article I linked probably has a more cogent explanation. :) ) CalendarViewContentPresenter: protected override Size ArrangeOverride(Size finalSize) { int columnCount = this.CalendarView.Periods.Count; Size columnSize = new Size(finalSize.Width / columnCount, finalSize.Height); double elementX = 0; foreach (UIElement element in this.visualChildren) { element.Arrange(new Rect(new Point(elementX, 0), columnSize)); elementX = elementX + columnSize.Width; } return finalSize; } protected override Size MeasureOverride(Size constraint) { this.GenerateVisualChildren(); this.GenerateListViewItemVisuals(); // If it's coming back infinity, just return some value. if (constraint.Width == Double.PositiveInfinity) constraint.Width = 10; if (constraint.Height == Double.PositiveInfinity) constraint.Height = 10; return constraint; } CalendarViewPeriodPersenter: protected override Size ArrangeOverride(Size finalSize) { foreach (UIElement element in this.visualChildren) { element.Arrange(new Rect(new Point(0, 0), finalSize)); } return finalSize; } protected override Size MeasureOverride(Size constraint) { this.GenerateVisualChildren(); return constraint; } RangePanel: protected override Size ArrangeOverride(Size finalSize) { double containerRange = (this.Maximum - this.Minimum); foreach (UIElement element in this.Children) { double begin = (double)element.GetValue(RangePanel.BeginProperty); double end = (double)element.GetValue(RangePanel.EndProperty); double elementRange = end - begin; Size size = new Size(); size.Width = (Orientation == Orientation.Vertical) ? finalSize.Width : elementRange / containerRange * finalSize.Width; size.Height = (Orientation == Orientation.Vertical) ? elementRange / containerRange * finalSize.Height : finalSize.Height; Point location = new Point(); location.X = (Orientation == Orientation.Vertical) ? 0 : (begin - this.Minimum) / containerRange * finalSize.Width; location.Y = (Orientation == Orientation.Vertical) ? (begin - this.Minimum) / containerRange * finalSize.Height : 0; element.Arrange(new Rect(location, size)); } return finalSize; } protected override Size MeasureOverride(Size availableSize) { foreach (UIElement element in this.Children) { element.Measure(availableSize); } // Constrain infinities if (availableSize.Width == double.PositiveInfinity) availableSize.Width = 10; if (availableSize.Height == double.PositiveInfinity) availableSize.Height = 10; return availableSize; }

    Read the article

  • UiButton / IBAction - link from a RootView to mainView in Storyboard

    - by webschnecke
    I try to call the main ViewController on my storyboard. In my app there is a additional .h, .m file with no xib or storyboard. In this .m file T craeted a button: UIButton *button = [UIButton buttonWithType:UIButtonTypeRoundedRect]; [button addTarget:self action:@selector(home:)forControlEvents:UIControlEventTouchDown]; [button setTitle:@"Show View" forState:UIControlStateNormal]; button.frame = CGRectMake(80.0, 210.0, 160.0, 40.0); [self.view addSubview:button]; NSLog(@"Home-Button line 645"); This button should link to my main ViewController in the Storyboard. The view has the identifier HauptMenu. I got no error, but the view doesnt change to my main ViewController. What is wrong? - (IBAction)home:(id)sender { NSLog(@"Button was tapped"); ViewController *viewController = [self.storyboard instantiateViewControllerWithIdentifier:@"HauptMenu"]; NSLog(@"1"); [viewController setModalTransitionStyle:UIModalTransitionStyleFlipHorizontal]; NSLog(@"2"); [self.navigationController pushViewController:viewController animated:NO]; [viewController release]; NSLog(@"3"); }

    Read the article

  • What is the differnce between DataTemplate and DataContext in WPF?

    - by Ashish Ashu
    I can set the relationship b/w View Model and view through following DataContext syntax: <UserControl.DataContext> <view_model:MainMenuModel /> </UserControl.DataContext> And I can also set the relationship b/w View Model and view through following DataTemplate syntax: <DataTemplate DataType="{x:Type viewModel:UserViewModel}"> <view:UserView /> </DataTemplate> Please let me know what is the difference between the two ? Is the second XAML does not set the data context of a view ?

    Read the article

  • How to explicitly select the row in ListView in WPF?

    - by Ashish Ashu
    I have a ListView in which one of the column contains combo box. I have binded the selectedItem of a Listview, so that I get the current object (selected row ) in the listview. When I do any operation in a combo box like selection change then the listview row ( in which that combo box belongs) is not selected be default and hence my selectedItem gives null or previous row selected object. Please Help!!

    Read the article

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