Archive for the ‘Silverlight’ Category

Silverlight 3: scrollbars not working

December 26, 2010

Silverlight and WPF share a lot… except for a few controls not jet available in SL3 ๐Ÿ˜ฆ
Based on my last post, Scrollbars not working, that solution doesn’t work SL3: DockPanel is not available ๐Ÿ˜ฆ
So, what could we do? ย Replace that StackPanel with a Grid!
Here is an example:

<Grid>
  <Grid.RowDefinitions>
    <RowDefinition Height="Auto" />
    <RowDefinition />
    <RowDefinition Height="35" />
  </Grid.RowDefinitions>

  <!-- search form -->
  <Grid Grid.Row="0"> ...</Grid>

  <!-- listbox results -->
  <ListBox Grid.Row="1">...</ListBox>

  <!-- buttons -->
  <Button Grid.Row="2">... </Button>
</Grid>

A simple tuning with RowDefinition‘s Height property (*, Auto, fixed, none) does the remaining part of the job. ๐Ÿ™‚
but this is another post ๐Ÿ˜‰

ps: Listbox has its own scrollbars, don’t forget it!

Technorati Tags: ,,.
Advertisements

[WPF/Silverlight] Image in button

December 12, 2010

Just a remind for myself. ๐Ÿ˜‰

In order to have a button’s image, you just need to implement custom content, this way:

<Button Name="ButtonImage" Width="24" Height="24">
    <Image Source="Images/arrow.jpeg" Stretch="Fill" />
</Button>

And if you want an upside down image,

<Button Name="ButtonImage" Width="24" Height="24">
    <Image Source="Images/arrow.jpeg" Stretch="Fill" RenderTransformOrigin="0.5,0.5">
        <Image.RenderTransform>
            <RotateTransform Angle="180" />
        </Image.RenderTransform>
     </Image>
 </Button>

Very simple, usefull in open/close – show/hide – enable/disable control (or panel) ๐Ÿ˜‰

Did you see HEIGHT and WIDTH properties, (only!) in button xaml code, and STRETCH in image xaml code ?

Neither 1 bit used in code behind. ๐Ÿ˜‰

Technorati tags: Silverlight, WPF

Silverlight and relative url images

December 5, 2010

There are some little tricks in every language, technology we use.
This is time for Silverlight3.
If you ย have an image, andyou want to reach it via relative url located outside ย ClientBin folder.
This way doesn’t work:

<Image Source="/Images/header.png" />

nor this one:

<Image Source="../Images/header.png" />

supposing your Image folder is located in root folder.

This way works fine:

<Image Source="..//Images/header.png" />

yes!!! ย double slash (“..//Images) ย make it works ๐Ÿ˜‰

Via code something like this sample:

    image = "..//Images/header.png";
    return new BitmapImage(new Uri(image, UriKind.RelativeOrAbsolute));

source: Setting Image.Source property to a value in the parent folder

Technorati tags: Silverlight

WP7: Silverlight & Bing Maps

October 31, 2010

MSDN has a very simple & usefull course about Silverlight & Bing Maps, in Windows Phone 7 ๐Ÿ˜‰

This course is located here: Silverlight for Windows Phone > Using Bing Maps

This course has been moved from Channel9, but links are invalid ๐Ÿ˜ฆ
Here I reconstruct the index, with correct links ๐Ÿ˜‰
Contents

  1. Overview: msdn | channel9 (google cache)
  2. Exercise 1: Introduction to the Bing Map Control: msdn | channel9 (google cache)
  3. Exercise 2: Handling and Customizing Pushpins: msdn | channel9 (google cache)
  4. Exercise 3: Calculating a Route: msdn | channel9 (google cache)

ps: Learn section on MSDN in very very usefull, with “How do I” videos, training courses on Windows Azure, Windows Phone 7, and … did’nt find a VB6 course ๐Ÿ˜€
If you never visited, better spend a minute having a look ๐Ÿ˜‰

Technorati tags: WP7,Silverlight, Bing Maps

Silverlight: where is my GridSplitter ?

October 25, 2010

Well, a WPF control, GridSplitter isn’t provided in Silverlight 3. ๐Ÿ˜ฆ
But, you can use it loading its assembly , ๐Ÿ˜‰
just add this to your xaml :

xmlns:ctrl=”clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls”

Then you can use your GridSplitter.
Very easy, ain’t it! ๐Ÿ˜‰

Here is complete source: Using the GridSplitter control in Silverlight

Technorati tags: Silverlight, XAML