Blog

posts tagged with xaml

DevDays 2011 Sessies

0 Comments
By Fons Sonnemans, 09-mei-2011

Ook dit jaar heb ik mogen spreken op het DevDays event van Microsoft dat op 28 en 29 april in Den Haag gehouden is. Deze keer met 3 sessies waarvan er twee op Channel9 te bekijken zijn. Helaas is mijn 'Windows Phone Marketplace' sessie van de Geeknight niet gepubliceerd.

READ MORE

WMAppManifest.xml changes for Silverlight WP7 Games

0 Comments
By Fons Sonnemans, 17-jan-2011

Games in the Games Hub of the Windows Phone 7 have larger icons than normal apps. If you are creating a game using Silverlight make sure you change the WMAppManifest.xml file which is located in the Properties folder of your project. You have to set the Genre attribute to 'apps.games'. This will place your game in the Game Hub. You must also change the IconPath from 'ApplicationIcon.png' to 'Background.png'. This image is 173x173 pixels instead of the smaller 62x62 icon which is used for the normal apps. You can even remove the 'ApplicationIcon.png' from your project because it isn't used any more.

WMAppManifest.xml for a Sample App

WMAppManifest.xml for a Sample App

WMAppManifest.xml for a Sample Game

WMAppManifest.xml for a Sample Game

READ MORE

Silverlight for Windows Phone 7 Toolkit artikel in .NET Magazine

0 Comments
By Fons Sonnemans, 10-jan-2011

 

In het laatste .NET magazine heb ik een artikel geschreven over Silverlight for Windows Phone 7 Toolkit. Dit artikel kunt u online lezen maar ook downloaden als PDF. Natuurlijk kan je de sourcecode van de demo applicatie ook downloaden.

Mocht je het magazine niet hebben ontvangen schrijf je dan alsnog in. Het laatste blad wordt dan alsnog opgestuurd.

READ MORE

Accent Colors for Styled TextBlocks in WP7 Selected ListBoxItems

0 Comments
By Fons Sonnemans, 12-nov-2010


The Problem
The Windows Phone tools in Visual Studio an Expression Blend let you create a 'Windows Phone Data Bound Application" (Template). This application uses SampleData and two List/Detail pages. The List (MainPage) contains a listbox which is templated. The ItemSource of this listbox is databound to the Items in the SampleData. When run the application and select an Item in the ListBox the DetailsPage is shown using navigation. This navigation is initiated from the SelectionChanged event of the listbox in the MainPage. When you remove this event from the XAML you would expect that the selected item in the listbox would be shown using the Accent color of your phone. But this doesn't happen. It took me a while to figure out the reason why, and how to solve it.

  <
  ListBox
  x:Name
  ="MainListBox"
  Margin
  ="0,0,-12,0"
  ItemsSource
  ="{Binding Items}">
  <
  ListBox.ItemTemplate
  >
  <
  DataTemplate
  >
  <
  StackPanel
  Margin
  ="0,0,0,17"
  Width
  ="432"
  >
  <
  TextBlock
  Text
  ="{Binding LineOne}"
  TextWrapping
  ="Wrap"
  Style
  ="{StaticResource PhoneTextExtraLargeStyle}"
  />
  <
  TextBlock
  Text
  ="{Binding LineTwo}"
  TextWrapping
  ="Wrap"
  Margin
  ="12,-6,12,0"
  Style
  ="{StaticResource PhoneTextSubtleStyle}"
  />
  </
  StackPanel
  >
  </
  DataTemplate
  >
  </
  ListBox.ItemTemplate
  >
  </
  ListBox
  >

The Reason
The Selected (Visual)State of a ListBoxItem sets the foreground of the ContainerControl to the PhoneAccentBrush resource. The Two TextBlockes in the ItemTemplete of my listbox have a Style Property. Both styles are base on the PhoneTextBlockBase which has a Foreground property set to the PhoneForegroundBrush resource. This conflicts with the foreground set in the VisualState and therefore the color never changes.

  <
  VisualStateGroup
  x:Name
  ="SelectionStates"
  >
  <
  VisualState
  x:Name
  ="Unselected"
  />
  <
  VisualState
  x:Name
  ="Selected"
  >
  <
  Storyboard
  >
  <
  ObjectAnimationUsingKeyFrames
  Storyboard.TargetProperty="Foreground"Storyboard.TargetName="ContentContainer"><DiscreteObjectKeyFrameKeyTime="0"Value="{StaticResource PhoneAccentBrush}"/></ObjectAnimationUsingKeyFrames></Storyboard></VisualState></VisualStateGroup>

READ MORE

Touch Gesture Triggers for Windows Phone 7 projects in Blend 4.0

0 Comments
By Fons Sonnemans, 04-jun-2010

The Windows Phone 7 supports single and multi touch gestures. I have implemented the Tap, Double Tap and the Touch&Hold gestures using Triggers. You can use them to trigger an Action in Expression Blend.

You first have to reference the GestureTriggersLibrary. Then you add an Action to a control using the Behavior assets. Finally you change the TriggerType using the New button.

The following example has tree TextBlock controls on with a ChangePropertyAction attached to it. This action sets the Text of the red TextBlock (textBlockResult) using the Tap, Double Tap or Touch and Hold GestureTriggers.

READ MORE

SpiralText in Silverlight 4

0 Comments
By Fons Sonnemans, 31-mei-2010

Blend 4.0 includes a new PathListBox control. In Silverlight 4 you can create your own shapes by deriving from the Path class. I have used these two techniques to create this SpiralText sample.

The Spiral class uses ArcSegment objects to create a spiral illusion. It isn't a perfect spiral but it is good enough for me.

The LayoutPath of the PathListBox is set to the Spiral. The ItemsSource is databound to the TextBox.

You can also select the Font, Color, Font Size, Font Spacing and the number of Spirals.

Get Microsoft Silverlight

READ MORE

RightMouseTrigger

0 Comments
By Fons Sonnemans, 09-mei-2010

I have written a Silverlight Minesweepe game in October 2008. I just published an improved version on Silver Arcade which support right mouse click. I implemented it using the following RightMouseTrigger. You can set the SetHandled property to true. This stops the MouseRightButtonDown event from bubbling to it's parent.

I really love Behaviors, Actions and Triggers. I hope you like it too.

public class RightMouseTrigger : EventTriggerBase<Control> {


    protectedoverridestring GetEventName() {

        return"MouseRightButtonDown";

    }


    #region SetHandled Dependency Property


    ///<summary>

    /// Get or Sets the SetHandled dependency property. 

    ///</summary>

    publicbool SetHandled {

        get { return (bool)GetValue(SetHandledProperty); }

        set { SetValue(SetHandledProperty, value); }

    }


    ///<summary>

    /// Identifies the SetHandled dependency property.

    /// This enables animation, styling, binding, etc...

    ///</summary>

    publicstaticreadonlyDependencyProperty SetHandledProperty =

        DependencyProperty.Register("SetHandled",

                                    typeof(bool),

                                    typeof(RightMouseTrigger),

                                    newPropertyMetadata(true));


    #endregion SetHandled Dependency Property


    protectedoverridevoid OnEvent(EventArgs eventArgs) {

        var ea = eventArgs asMouseButtonEventArgs;

        if (ea != null && SetHandled) {

            ea.Handled = true;

        }

        base.OnEvent(eventArgs);

    }


}

READ MORE

CountDown Clock in Silverlight 4

0 Comments
By Fons Sonnemans, 01-apr-2010

A while ago I wrote a FlipClock Silverlight 3 application. I have modified it into a CountDown Clock which you can configure using InitParams. It is written in Silverlight 4 and uses the new Viewbox control to make it scalable. I hope you like it.

You can download the sourcecode from here.

Get Microsoft Silverlight

< object data ="data:application/x-silverlight-2," type ="application/x-silverlight-2"

    width="400"height="200">

    <paramname="source"value="ClientBin/ReflectionIT.Silverlight.CountDown.xap"/>

    <paramname="initParams"value="title=Silverlight 4 RTW,date=2010-04-13 08:00AM-8:00"/>

    <paramname="background"value="white"/>

    <paramname="minRuntimeVersion"value="4.0.50303.0"/>

    <paramname="autoUpgrade"value="true"/>

    <ahref="http://go.microsoft.com/fwlink/?LinkID=149156&v=4.0.41108.0"style="text-decoration: none">

        <imgsrc="http://go.microsoft.com/fwlink/?LinkId=161376"alt="Get Microsoft Silverlight"

            style="border-style: none"/>

    </a>

</ object >

 

Get Microsoft Silverlight

READ MORE

DevDays 2010 Materiaal

0 Comments
By Fons Sonnemans, 01-apr-2010

Zoals beloofd kan je de Presentatie + Demo's van mijn 'Introduction to WCF RIA Services' sessie van de DevDays downloaden. Je dient eerst wel de Northwind database te installeren op localhost\SQLEXPRESS. Het benodigde installatiescript is ook in de ZIP file opgenomen. 

READ MORE

Mijn WCF RIA Services sessie op DevDays 2010

0 Comments
By Fons Sonnemans, 17-feb-2010

Op 30 en 31 maart a.s. vinden de Microsoft Development Days (DevDays) plaats. DevDays is een evenement dat al 13 jaar dé bron van kennis en inspiratie voor IT ontwikkelaars is. Ook deze keer vinden de DevDays plaats in het World Forum in Den Haag.

Dit jaar zijn de DevDays voor mij extra speciaal omdat ik door Microsoft ben gevraagd om als spreker op de DevDays te verschijnen. Op dinsdag 30 maart mag ik een sessies verzorgen over een onderdeel van Silverlight 4, namelijk WCF RIA Services. Met een goed doordacht Framework, op basis van codegeneratie, wordt hiermee het bouwen van gedistribueerde Silverlight applicaties veel eenvoudiger.

Wilt u ook naar mijn sessie komen luisteren, maar heeft u zich nog niet ingeschreven, ga dan naar www.devdays.nl, want ook u bent uiteraard van harte welkom.

READ MORE

All postings/content on this blog are provided "AS IS" with no warranties, and confer no rights. All entries in this blog are my opinion and don't necessarily reflect the opinion of my employer or sponsors. The content on this site is licensed under a Creative Commons Attribution By license.