Jaime Rodriguez
On Windows Store apps, Windows Phone, HTML and XAML

  • Jaime Rodriguez

    Announcing the "WPF for LOB" Training Tour..

    • 33 Comments

    After our m-v-vm training sold out, and most of the march trainings were filled within days, I am delighted to announce our new series of WPF trainings for April/May/June.   

    Karl Shifflett and I created our best offering to-date: two days packed with WPF, optimized for building business applications, and in your neighborhood. We are hitting five different cities this time!!

    Please join us, and please help us spread the word about the training!!

    Update on 4/2  -- Added registration tips; a lot of people were wondering about partner requirements; there are none. This training is open to every one. Sorry for asking those questions, we are tagging on existing infrastructure for registration.

    Update on 4/8Dates are now final and the good news is the events were moved up. The NY and PHX dates changed, but registration opened with right dates so any one who registered saw the right ones!

    Here is the full-invite:


    Overview
    This two day training is designed to teach developers how to create Line of Business (LOB) applications using Windows Presentation Foundation (WPF).  

    • Day One is an introduction to the WPF graphics subsystem, the tools used to build WPF applications, and the core UI services: styling, data binding, templating, layout and input-
    • The second day begins with interop (Windows Forms and Win32)  and then quickly dives into LOB topics, including building applications using the Model-View-ViewModel pattern, creating unit testable applications,  implementing data validation, and error handling.  

    After completion, attendees will have a solid understanding of WPF, its advantages over other Microsoft UI platforms, and how to use the M-V-VM pattern to create great WPF LOB applications.

    Date, Location, and Logistics

    Location

    Dates

    Click here to register (see tips below)

    Los Angeles, CA

    4/24 -4/25

    www.msregistration.com/wpflobLA

    London, UK

    5/15 -5/16

    www.msregistration.com/wpflobUK

    New York, NY

    5/29-5/30

    www.msregistration.com/wpflobNY

    Chicago, IL

    6/12-6/13

    www.msregistration.com/wpflobIL

    Phoenix, AZ

    6/5-6/6

    www.msregistration.com/wpflobAZ

    Registration tips:
    If you are not a partner or don't know if you are:
          When asked "are you registered" select No.  Select "Visiting partner" under Partner Level.
          Get creative on the Partner Type;  if in doubt, we are all "System builders"
     

    Format:
    Instructor-led training from 9 AM to 5:30 PM.   15 minute breaks every couple hours. 45 minutes lunch around mid-day.
    Food:
    Breakfast, lunch and afternoon snacks are provided.

    Cost
    The training is FREE. You do need to register prior to the event, but there is no cost.  You can register for one or two days. Registration is first-come-first serve, sign-up as early as possible to reserve your spot!


    Detailed Agenda

    • Day One:
      • Lap Around WPF
      • WPF Tools ( Blend, Visual Studio 2008)
      • Graphics Subsystem
      • Layout
      • WPF Fundamentals and new concepts
        • Application Model
        • Dependency Properties
        • Trees (logical & visual)
        • Events
        • Threading
        • Resources
      • Controls
      • Styling
      • Templating
      • Q&A with instructors at end of day
    • Day Two:
      • WPF integration with Win32 and Windows Forms
      • Data binding
      • Introduction to Model-View-ViewModel
      • Commanding in M-V-VM
      • Views, Navigation and Transitions
      • Data Validation
      • Error handling, Model dialogs, Logging
      • Unit Testing
      • MVVM & LOB tips and tricks
      • Q&A with the instructors

     

    About the instructors
    Karl Shifflett is a software architect, former Microsoft MVP, current Code Project MVP and MCAD from Bellevue, Washington. He is currently working for Microsoft on the Cider Team as a Program Manager II. He has been designing & developing business applications since 1989 and transitioned to .NET in March of 2003. In April of 2007 he joined the list of WPF and Microsoft Expression fanatics & evangelists. He is a member of Team Mole that delivered Mole Visualizer For Visual Studio to the world. He is the author to XAML Power Toys and loves WPF LOB.  Karl’s Blog: http://karlshifflett.wordpress.com/

    Jaime Rodriguez is a Senior Technical Evangelist at Microsoft. He focuses on WPF and Silverlight.   For the last four years, he has helped a lot of enterprises and ISVs adopt WPF in large scale, mission critical, projects. 
    Jaime has been doing software development for fifteen years. Prior to Microsoft, he worked at Xerox, HP, Cerner and GeoAccess.   He joined Microsoft 9 years ago, he spent the first four years as an Enterprise Architect Consultant in Microsoft Services, and the last five he has been a client evangelist covering Windows Forms, WPF and Silverlight.  Jaime’s blog is at http://blogs.msdn.com/jaimer


  • Jaime Rodriguez

    Thank You LA!! Here is the content

    • 7 Comments

    Last week we had our first stop in the WPF for LOB tour: Los Angeles.    hOLLYWOODxamlIZEDThe training went very well!  Attendees were very engaged and they kept up with a lot of content in a short time-span; from what I heard, they learned quite a bit.

    Karl and I learned a bit too! We are already refining our content for the next stop:
    London (on 5/15 and 5/16) at the
                  Radisson Edwardian Heathrow Hotel
                  140 Bath Road
                  Hayes Middlesex , London

    Thanks LA! The content for the training is here: decks (30 mb), demos (15mb) 


    If you have not signed up for your training ( in London,  NY, Chicago, or Phoenix), I recommend you get to it soon; London and NY are already full, but we are adding names to the waiting list.   Chicago and Phoenix are getting there!.   Huge thanks to all those helping us spread the word!

    London residents, see you soon!    LA attendees, thanks again!! It was a lot of fun!!

  • Jaime Rodriguez

    Robby Ingebretsen’s design for developers MIX09 workshop now online..

    • 4 Comments

    The MIX09 team just posted Robby Ingebretsen’s:   “Design for developers workshop.


    Robby knocked it out of the ball park with his workshop.   
    This is a must watch (multiple times) for most developers wanting to understand design.
    I hope you enjoy it as much as every attendee did.  Click on the image on the right to go to MIX site and watch.

    We posted three videos as an asx. If you want to download, here are direct links:
        Part One: Process
        Part Two: Composition
        Part Three:  Visuals

    Enjoy!!


     

     


     

    A few comments or disclaimers around workshops:
    The workshops and pre-cons are not posted online because they cost extra. So for other conferences, please do not expect this.
    In this case, workshops were recorded to test the cameras and accidentally posted on-line earlier, but encoding was not good; we heard from lots of people that they wanted to watch it,  including people who had paid to attend; when we asked those that paid if it was OK to post for everyone they agreed, so thank them for it, but again, don’t assume this will repeat again (it is not up-to-me).

    What about the other workshops?
    Hiking Mt. Avalon (my workshop) should be posted next. The Mix online guys are doing this one at a time so they can say I owe them four favors instead of one; either that or it takes a day to encode and they are working on it.
    We are looking at the other workshops to see if the quality is good enough.  I can’t promise any other workshops yet; I do know that Molly’s workshop was not recorded.

  • Jaime Rodriguez

    Announcing WPF TestAPI 0.2 release

    • 1 Comments

    Last week, the WPF test team released a new version of their Test API: 0.2.  You can download the new release from their codeplex site.

    The Test API is a library with utilities for testing WPF and Windows Forms applications. 

    In their 0.2 release, the library includes APIs to simulate input and do visual verification; it also includes handy utilities that can be used for tasks beyond testing, like a command line parsing ,  and APIs to drive the WPF dispatcher.
    The library is not VSTS specific; in their 0.2 releases they added nUnit and xUnit samples.

    The best way to learn about the lib this is to download it, play with it and read their docs;  that said, if you want to learn more before you download, Ivo the WPF test manager has some good blog posts on their 0.1 release. 

    For feedback,  you can go to the codeplex forums.  They need help prioritizing the features in the next version. Among the most interesting ones, I see controls verification, state management APIs, property comparisons, performance, and leak detection.  I am voting for the last two!!  How bout u?

  • Jaime Rodriguez

    wpf discussions.. 090403

    • 1 Comments

    You know the drill.. raw, unedited, yet deep and useful WPF conversations !!


    Subject: Changing Resources from Triggers

    I have a complex ControlTemplate that I want to change colors when the mouse is over it.  The colors are used at various places deep within the template, and some are even in nested templates …. …

    Answer:
    To change Resources on a Trigger is to change a non-DP property on a Trigger. WPF does not currently support this. As a workaround could you try the following pattern?

    <ControlTemplate>
      <SomeElement1 x:Name="element1">
        <SomeElement1.Style>
          <Style>
            <Style.Resources>
              <SomeResource1 x:Key="blah" />
            </Style.Resources>
          </Style>
        </SomeElement1.Style>
        <SomeElement1.Template>
          <ControlTemplate>
            <SomeElement1_1 SomeProperty="{DynamicResource blah}" />
          </ControlTemplate>
        </SomeElement1.Template>
      </SomeElement1>
      <ControlTemplate.Triggers>
        <Trigger Property="AnotherProperty" Value="anotherValue">
          <Setter Property="Style" TargetName="element1">
            <Setter.Value>
              <Style>
                <Style.Resources>
                  <SomeResource2 x:Key="blah" />
                </Style.Resources>
              </Style>
            </Setter.Value>
          </Setter>
        </Trigger>
      </ControlTemplate.Triggers>
    </ControlTemplate>

    Subject: Creating WPF window prevents application from closing
    Window window = new Window();
    Putting this line anywhere in my WPF application without actually using this window variable prevents my application from closing when I hit the main window close button. Why would creating an instance of Window have this effect? Only if I add a subsequent window.Close() call does my application shut down correctly.

    Window window = new Window();
    window.Close();

    Answer:
    If you do Application.Current.Shutdown() your app should close.
    I assume you’re doing Application.Current.MainWindow.Close().  There’s a property on Application called ShutdownMode.  The default is OnLastWindowClose.  Since you’ve created a window and not closed it, your app will never shut down.  You can change Application.ShutdownMode to OnMainWindowClose, and you should be fine.


    Subject: Coerced value not reflected in control or others bound to it as sources

    I have the following xaml. The CustomTextBox overrides metadata for the Text Dependency Property, which calls a coerce method, which upshifts whatever the user enters. However, the upshifted value does not show up in either TextBox. If I move the binding to the 2nd text box, so it binds to the first, it will display the upshifted text correctly. Why is the upshifted string not showing up in the original case (i.e. as below)?

    <StackPanel Margin="20" VerticalAlignment="Center">

    <Label Content="Target TextBox (with coercion to uppercase)"/>

    <src:CustomTextBox x:Name="TargetTextBox"

    Text="{Binding ElementName=SourceTextBox,

           Path=Text, Mode=TwoWay,

           UpdateSourceTrigger=PropertyChanged}"

    Margin="0,0,0,20"/>

    <Label Content="Source TextBox"/>

    <TextBox x:Name="SourceTextBox" IsReadOnly="True" Background="LightGray"

    Margin="0,0,0,20"/>

    </StackPanel>

    Answer:
    Here’s a bit of background on coercion. The classic case of coercion is the Slider control where the Value property’s value needs to always lie between the MaxValue and the MinValue. So in this regard we envisioned Coersion to be a view concept. Hence we made a design decision not to propagate coerced values through data Binding. Thus the fact that you don’t see a coerced value on CustomTextBox.Text propagate through the Binding back to the source is ‘By Design’. Yes it can be argued that when Binding is used in the way you’ve shown below to bind two UI pieces then one would want to propagate the coerced value through the Binding. Sam Bent (our Data Services guru), has some thoughts on building some configuration parameters on Binding to allow this. However none of that exists in the platform as of today. As for a Binding on a regular TextBox.Text property displaying the upshifted Text, the reason is that the value at the source is transferred as is to the target of a Binding. The special rule about coercion only comes into play when the value at the target is being coerced. 


    Subject: Creating Bindings in a Data Template

    I’m trying to create a DataTemplate where some non-FE objects bind to the DataContext of the DataTemplate.  My XAML looks something like this?

    <DataTemplate DataType="{x:Type api:SeahorseItem}">
          <Button CommandParameter="{Binding RelativeSource={RelativeSource Self}}">
            <con:DoubleClickButton.Command>
              <con:MetaCommand CommandParameter="{Binding}">
                <con:MetaCommandEntry Command="FocusCommand" CommandParameter="{Binding }" />
                <con:MetaCommandEntry Command="OpenCommand" CommandParameter="{Binding }" />
                <con:MetaCommandEntry Command="OpenInBackgroundCommand" CommandParameter="{Binding }" />
              </con:MetaCommand>
            </con:DoubleClickButton.Command>
          </Button >
        </DataTemplate>

    When I run my application I get the following error message:

    System.Windows.Data Error: 2 : Cannot find governing FrameworkElement or FrameworkContentElement for target element. BindingExpression:(no path); DataItem=null; target element is 'MetaCommandEntry' (HashCode=51095287); target property is 'CommandParameter' (type 'Object')

    When I actually debug this, the CommandParameters on my entries and the command itself are null.  I’ve done some digging, and it seems that my problem is that my objects are not FEs, and as a result not part of the inheritance tree.  I also saw a neat trick that allows me to make my objects a part of the inheritance tree by making them freezables.  This worked for the MetaCommand, allowing it’s binding to work. But the Entries still evaluate to null. 

    Answer:
    Could you make the collection property that holds on to the MetaCommandEntries be of type FreezableCollection<MetaCommandEntry> and MetaCommandEntry should also subclass Freezable. The reason for these changes is that InheritanceContext is internal to the framework and Freezable and FreezableCollection are the only two non-FE/FCE public classes that support it.


    Subject: DataGrid different template for new row problem.

    I’m trying to show a different template for the last row of my DataGrid to show not the default row template but show a line of text say “Click here to add new item”.

    I came across this blog http://blogs.msdn.com/vinsibal/archive/2008/11/05/wpf-datagrid-new-item-template-sample.aspx

    I improved it a little bit by listening to InitializingNewItem event and saved the Dispatcher trick. But I still need to listen to several event, use VisualTreeHelper to set the focus on the first cell of last row. I wonder if there is a easier way to do this in general. I believe this is a very common scenario.

    Answer:
    We hear you. We will look to make this scenario easier in a future release. But what you see in the blog is what we have today.


    Subject: Font change events?

    I need to detect when font setting for a specific element in my FlowDocument changes, either because it’s (local) font property or its container’s property (inheritable) changes. Is it possible? (I do not see an event that looks that way; I need to change some other properties because of the font change). Alternatively, is there any way for me to detect that the document is about to re-render and do these mods then?

    Answer:
    You could try DependecyPropertyDescriptor.AddValueChanged. The dependency property would be TextElement.FontSizeProperty


    Subject: How to display 1st underscore in Label ?

    I would like to display 1st underscore “_” in Label. I know 1st “_” means keyboard shortcut. But he don’t use shortcut but want to display it. How to escape make “_” shortcut ?

    Obvious Answer:
    Try double “_” as markup below.
    <Label Content="__Label"/>

    Follow-up:
    Yes, I did, but I have to add extra underscore to all underscore such as A__B__C__D instead of A__B_C_D.

    Next answer:

    The simplest solution would be to use TextBlock instead of Label. Otherwise, you could re-template Label to change RecognizesAccessKey to false :

        <ControlTemplate TargetType="{x:Type Label}">
          <Border ...>
            <ContentPresenter ... RecognizesAccessKey="False" SnapsToDevicePixels="{TemplateBinding SnapsToDevicePixels}"/>
          </Border>
          ..
        </ControlTemplate>
    

    Subject: Is there any easy way to get the size of a ImageSource

    I'm implementing a cache for ImageSource. I was looking the documentation but I could not find a easy way to get the Size (in bytes) of a ImageSource. Is there a easy way to do that?

    Answer:
    A size property doesn’t make sense for all implementers of ImageSource. The two platform ones (according to MSDN) are DrawingImage and BitmapSource. DrawingImage is specified in XAML, so its size would not be representative of a pixel width x height x depth measure in bytes.

    Take a look at the ImageSource documentation and inheritance tree:

    http://msdn.microsoft.com/en-us/library/system.windows.media.imagesource.aspx

    You can get a size for the pixels of a BitmapSource using PixelWidth, PixelHeight, and Format.BitsPerPixel. Obviously the object itself can store some more information depending on the implementation. So I think you might want to implement a cache for the BitmapSource class rather than ImageSource


    Subject: Closest to immediate-mode rendering in WPF

    What is the closest I can get to immediate-mode rendering in WPF? Right now I’m overriding OnRender and basically re-populating the DrawingContext on every frame (since a physics engine is involved, everything moves). Is that the best way?

    Also, I noticed that there is no way to apply pixel shaders in the DrawingContext like we can do in XNA. Is there any (potentially hacky) way to push a pixel shader into DrawingContext? Seems odd that we can push bitmap effects but not hardware accelerated effects.

    Answer:
    That’s as close as it gets. Not sure if it matters to you, since you’re changing everything every frame, but it’s probably worth noting that the dirty region logic operates at the Visual level. Which is to say if you draw everything in 1 DrawingContext, you get no dirty subregion support for all that content.

    Having said that, what exactly is changing in your scene? If things are moving/rotating while maintaining a rigid shape, it might make more sense to draw everything once, then simply update the transforms every frame with the physics engine inputs. This is much more “WPFy”, and if it fits within the constraints of your system, it should also be more efficient than changing the DC content every frame.

    No way to push an effect in a DC. The method of drawing you’re using is not really the one for which WPF is optimized.

    Bitmap effects are going away. If you pick up a 4.0 beta build, they’re already gone.


    Subject: Making one color in a bitmap transparent

    I’m fairly new at WPF, so if there is an obvious answer to this question, it’s likely the right one.

    I’m trying to convert some old WinForms code to WPF and I’m running into a snag displaying Bitmap images.  All of the bitmaps in my application have the same background color which is intended to be displayed as transparent.  In WinForms I could achieve this effect by creating an ImageList and setting the TransparentColor property to be this particular color. 

    How can I achieve the same effect with WPF?

    Answers:

    There's no default support in wpf to do this.  However Dwayne has blogged about how to do this.http://blogs.msdn.com/dwayneneed/archive/2008/06/20/implementing-a-custom-bitmapsource.aspx
    If you have a small number of bitmaps, it’s probably easier to make them transparent yourself in a photo editing app and save as PNG.

Page 1 of 1 (5 items)