Blog Archives

Quick Tip: a work around the RadListBox’s SelectedIndex issue with Telerik Q1 2013

If you are working with Telerik RadListBox for Silverlight or WPF and if you upgraded your Telerik version to the Q1 2013 , you probably noticed that there is something wrong with it.

Basically the problem is when SelectedIndex is changed , the SelectedItem property is not updated and vice versa.

A classic scenario is when you try to set a by default selection:

_myListBox.SelectedIndex = 0;

If(_myListBox.SelectedItem != null)

   {

       //Do something

   }

This is not working anymore with Telerik Q1 2013 because SElectedItem is not updated.

What you can do is instead of  _myListBox.SelectedIndex = 0;

put  _myListBox.SetValue(RadListBox.SelectedItemProperty, _myListBox.Items[0]);

 

Wala Sourire

Advertisements

Mango – Baby Steps: Creating your first application

Mango – baby steps are a serie of posts to learn about Windows Phone 7.1 and you probably know that if you read the first post aiming to help you to set up the environment and know the requirements in order to start writing some rocking code.

Now everything is set , let’s start coding !!!!!

Open a new project

In visual Studio , from the menu in the top, click : File –> New –> Project

When you choose Silverlight for Windows Phone from the installed templates, you will get this window :

As you can notice, you have multiple choices:

  • Windows Phone Application : Generates a basic application with a single start page and header.
  • Windows Phone Databound Application: Generates an application in a Model/View/ViewModel (MVVM) style, with sample data exposed in ViewModel classes.
  • Windows Phone Class Library:  Enables you to create a collection of controls that you can reuse across several projects.
  • Windows phone Panorama Application: This template creates an application with the Panorama Control, which provides a multipage view of options with a parallax scrolling background.
  • Windows Phone Pivot Application:  The Pivot control is much like a Tab Control, but tuned for a gesture-based interface. This template creates an application with the Pivot as its primary navigation.
  • Windows Phone 3D Graphics Application: the application type used to invoke XNA content from a Silverlight application. The idea behind this application is to have a pre-built XAML page that has a game loop and that is calling an included XNA project. This can be considered a pure demo of Silverlight-XNA interop.
  • Windows Phone Audio Playback Agent: a non-UI project time that creates a class based on AudioPlayerAgent. Consider this some sort of a class library, but that will later be tied to a BackgroundAudioPlayer to handle custom events.
  • Windows Phone Audio PStreaming Agent: similar to the audio playback agent, this project is used to create a class that will be used with an application that implements a streaming mechanism coupled with a background player.
  • Windows Phone Task Scheduler Agent: a project that will create a class based on ScheduledTaskAgent that will allow developers to handle task invocation events for existing scheduled tasks.

Since it’s our first application, we will choose a simple Windows Phone Application template and call it ” Hello Mango”. Make sure you select ” Windows Phone 7.1″ version.

Add some controls to the application

Now that the project is created, we will get this window:

That doesn’t look so nice :S

We will change the application and page titles :

Before

After

In the XAML code, i changed :

  •  the text of the textblock named ” Application Title” from ” Application title” to ” Hello Mango” .
  • the text of the textblock named ” Page title” from ” page title” to ” Home page” .

Let’s add the Mango picture to the page:

In the  solution explorer, right click on the project : add –>  existing item

Then browse the location where you saved the image, selected and click add.

from the toolbox, drag and drop an ” image” control to the phone interface :

In order to see the image we added to the project, we need to give the “image” control a ” source” , to specify the path of the image to be visualized.

Run the application in the Emulator

Now let’s see the app in action and discover the emulator new features.

The Mango’s new emulator has some additional tools like the accelometer and location:

This is a first example, it aims to explain the templates and explore the elements in the window.

Please feel free to comment and give me your feedback 🙂

Digest Mango

If you are reading this post because you love eating Mango !! Sorry , wrong blog -_-

Mango is the codename for the new Windows Phone and you can call it also Windows Phone 7.1 .

Users have to wait for Mango, Joe Belfiore , Microsoft vice president and director of Windows Phone program Management, said that Mango will be available in fall 2011 and developers will probably get the Mango update in a month ! Yeahhh just another 4 weeks 😀

But you can test and explore the new Mango features ! The beta Windows Phone 7.1 developer tools were released on 24 May 2011 and you can download them from here .

Mango offers lots of new capabilities for developers , you can experience all the new developer features with the offline training course and the pre-release documentation .

Microsoft said that Mango contains about 500 new feature !!!! Let’s see the most important features:

  • Windows Live Messenger and Facebook chat integration.
  • Twitter , LinkedIn and Viadeo integration in the people hub.
  • Outlook tasks support.
  • Office 365 support with Skydrive and Sharepoint integration.
  • Microsoft Lync support.
  • Video uploads to Facebook.
  • Support for HTML5 video playback.
  • IE9 for Windows Phone.
  • 16 new languages supported

and more and more features , i will let you discover them by yourselves.

You probably want to take a look to those links for  a better digestion to Mango :

 

I hope that was helpful , more to come about Mango 🙂

 

Silverlight 5 beta to be released during Mix11

Few days before the Mix11 where .Net developers and PROs expect to see the latest components coming with Silverlight5.

Microsoft officially announced the release of silverlight 5 beta during Mix11 in the Silverlight Team Blog :” As part of the continued support for scenarios that require plug-in based capabilities, we will ship a beta of Silverlight 5 at MIX, with some great demos for compelling scenarios. And as we stated in the summary above, we believe Silverlight delivers the richest set of plug-in based capabilities available to developers today, making the choice of Microsoft technologies even more compelling in aggregate.”

As announced in the last Silverlight FireStarter, Silverlight 5 will support new features like the 3D graphics programming interface, debugging inside the binding and other great features.

Stay tuned to see some great Silverlight5 beta demos in Mix11 !!

Silverlight Toolkit for Windows Phone 7

Finally the official Windows Phone Developer tools are out and a Silverlight toolkit containing a series of controls/librairies is released.

The toolkit includes:

*ContextMenu control

*DatePicker and TimePicker controls

*WrapPanel control

*ToggleSwitch control

*GestureHelper library

Here’s a quick look to how to use those controls so you can enjoy them:

After adding a reference to the Microsoft.Phone.Controls.Toolkit assembly, you need to declare the ” Toolkit” prefix on the controls in the app:

1:   xmlns:toolkit=”clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone.Controls.Toolkit”

2:xmlns:toolkitPrimitives=”clrnamespace:Microsoft.Phone.Controls.Primitives;

assembly=Microsoft.Phone.Controls.Toolkit”

ContextMenu

<Border
    Background="{StaticResource PhoneChromeBrush}"
    Padding="20">
    <toolkit:ContextMenuService.ContextMenu>
        <toolkit:ContextMenu>
            <toolkit:MenuItem
                Header="gray text"
                Click="MenuGrayTextClick"/>
            <toolkit:MenuItem
                Header="normal text"
                Click="MenuNormalTextClick"/>
        </toolkit:ContextMenu>
    </toolkit:ContextMenuService.ContextMenu>
    <TextBlock
        x:Name="MenuTextBlock"
        Text="Tap and hold for ContextMenu"
        HorizontalAlignment="Center"/>
</Border>

DatePicker and TimePicker

<toolkit:DatePicker
    Header="Date"
    Value="25/09/2010"
    ValueChanged="DatePickerValueChanged"/>
<toolkit:TimePicker
    Header="Time"
    Value="10:34 pm"
    ValueChanged="TimePickerValueChanged"/>

WrapPanel

 <toolkit:WrapPanel Orientation="Horizontal">
    <Rectangle Fill="Blue" Width="100" Height="100" Stroke="Black" />
    <Rectangle Fill="Red" Width="100" Height="100" Stroke="Black" />
    <Rectangle Fill="Green" Width="100" Height="100" Stroke="Black" />
    <Rectangle Fill="Gray" Width="100" Height="100" Stroke="Black" />
    <Rectangle Fill="Yellow" Width="100" Height="100" Stroke="Black" />
    <Rectangle Fill="Orange" Width="100" Height="100" Stroke="Black" />
    <Rectangle Fill="Teal" Width="100" Height="100" Stroke="Black" />
    <Rectangle Fill="White" Width="100" Height="100" Stroke="Black" />
    <Rectangle Fill="Pink" Width="100" Height="100" Stroke="Black" />
    <Rectangle Fill="Magenta" Width="100" Height="100" Stroke="Black" />
 </toolkit:WrapPanel>

ToggleSwitch

<toolkit:ToggleSwitch
    Header="ToggleSwitch feature"
    IsChecked="true"
    Checked="ToggleSwitchChanged"
    Unchecked="ToggleSwitchChanged"/>

You can freely use these controls in your applications after downloading the Silverlight for Windows Phone Toolkit.

Enjoy 🙂