in

WPF Design and Development

IdentityMine Team Blogs

Sajiv Thomas

WPF DataBinding, 3D, Graphics, Controls, Silverlight
  • Blendables EvalBinding: Trigger without a Trigger

    After going through the whitepaper for Blendables, I discovered a way to implement a trigger without using the conventional WPF trigger. Confused? Check out the markup below:

    <Grid>

    <Rectangle Grid.Row="2" RadiusX="2" RadiusY="2" Height="100" Width="200" Stroke="Black" Fill="Olive"

    Opacity="{blendables:EvalBinding [{Self}.IsMouseOver] ? 1 : 0.7}"/>
    </Grid>

     EvalBinding adds a lot of power to WPF databinding. Keep up the good work Jonathan!!

    Here is a sample.

    Note: You need to download and install Blendables for this sample to work.

    Posted Jan 18 2008, 02:53 AM by Sajiv with no comments
    Filed under:
  • Silverlight 1.0 Carousel

    I tried creating a stripped down version of a Carousel control (in Silverlight 1.0) which displays images. As of now it just rotates in the clockwise direction on ‘MoueEnter’. I will try to add more features to it as I move on to Silverlight 1.1. You can see it runing here. Here is the Source. 
      
    Posted Nov 07 2007, 03:33 AM by Sajiv with 1 comment(s)
    Filed under:
  • How to change the Source property of a Frame control in WPF?

     

    Suppose we have a Frame control in our application and it inherits it’s ‘DataContext’ from its parent Window. If we need to change the ‘Source’ property when a certain condition is true then we could style the Frame as seen below:
    <Style x:Key="FrameStyle" TargetType ="{x:Type Frame}">

    <Setter Property="Source" Value="{Binding XPath=@Path}"/>

    <Style.Triggers>

    <DataTrigger Binding="{Binding XPath=@IsRedirectionRequired}" Value="Yes">

    <Setter Property="Source" Value="{Binding XPath=@AlternatePath}" />

    </DataTrigger>

    </Style.Triggers>

    </Style>

     We are assuming that our DataSource is an XML file which contains the path to various loose XAML files and an alternate path for each. Something like this.
    <Files>

    <File Name="File1" Path="http://www.identitymine.com" AlternatePath="http://www.blendables.com/" IsRedirectionRequired="Yes"/>

    <File Name="File2" Path="http://www.google.com" AlternatePath="http://www.msn.com" IsRedirectionRequired="No"/>

    </Files>

     Here is a sample. 

     

     #Note: Setting the ‘Source’ or ‘Content’ property on the Frame locally (either using DataBinding or hard coded values) as seen below will result in the style having no effect.
    <Frame Source="{Binding XPath=@Path}" Grid.Column="1" Width="Auto" Height="Auto" Style="{StaticResource FrameStyle}" />
     
    Posted Nov 07 2007, 12:59 AM by Sajiv with no comments
    Filed under:
  • Formatting data in WPF DataBinding.

    An easy way for formatting data according to our needs in WPF data binding is to use a Converter alongwith a ConverterParameter.

    As seen below, all we need to do is write a converter which takes Format String as a parameter. Inside the converter we can format the data based on the Format String passed in as the converter parameter.

     

    <TextBlock Text="{Binding Path=Price,Converter={StaticResource formatter},ConverterParameter='\{0:C\}'}"/>

     

    Note:Since the Format String has curly brackets we need to escape these using backslash.

    Posted Aug 03 2007, 01:27 AM by Sajiv with no comments
    Filed under:
  • WPF-Interactive3D Toblerone

     

    Interactive 3D for WPF has been around for some time now. I created this sample a few months ago using 3DTools from codeplex, when Interactive 3D was first relesed by Microsoft . The sample has a 3D model of a Toblerone. Each phase of the Toblerone shows a visual. Interactive 3D helps in interacting with the visuals painted on 3D surfaces as you would expect in 2D.
    Posted May 22 2007, 02:21 AM by Sajiv with no comments
    Filed under:
  • WPF 3D Clock

    Here is a WPF 3D Clock which I developed as a part of WPF 3D learning. It is a 3D model of a clock which shows the current system time. So, the dial, hands, casing for the clock are all 3D Models. I have written a simple Radial Panel to layout the digits on the dial. Once the digits were laid out using the panel, I used it to create a visual brush. This visual brush was in turn applied to 3D-Plane as the material. The hands are rotated on every tick of a ‘DispatcherTimer’. As a whole, it was a very good learning experience. This application uses a ‘trackball’ which is freely available as part of 3DTools. You can use the trackball to rotate the clock and also to Zoom In/Out. Thanks to WPF which makes it relatively easy to develop interesting UI. Source code is attached for reference.

    Posted Apr 02 2007, 11:48 PM by Sajiv with 1 comment(s)
    Filed under:
  • Implementing Master-Detail made easy in WPF.

    We often need to implement master-detail scenarios in our applications.

    ListBox (also ComboBox) has a property called IsSynchronizedWithCurrentItem which makes it very easy to implement master-detail scenarios.

    You can set the IsSynchronizedWithCurrentItem property to true to ensure that the item selected always corresponds to the CurrentItem property in the ItemCollection(source of data for the ListBox).

    For example, if we need to have Listbox(MasterList) showing images of products and a details pane showing details of the image selected in the ListBox.

    All we need to do is set the DataContext for the ListBox and details pane to the same ItemsCollection and set the IsSynchronizedWithCurrentItem on the ListBox to true.

    You can find the source code attached.

    #Note: This sample uses no C# code, only XAML.

    Here is an interesting link on Selection Synchronization

     

    Posted Mar 26 2007, 02:57 AM by Sajiv with no comments
    Filed under:
More Posts
© 2007 IdentityMine, Inc.
Powered by Community Server (Commercial Edition), by Telligent Systems