Archive for the ‘Silverlight’ Category

XAML: blend behavious and markup extensions

November 18, 2012

A book, an article, a blog post … but a good lesson is something you cannot miss!

Here is Miguel Castro sessions, last NDC 2012: Extending XAML To Overcome Pretty Much Any Limitation.

2nd part is about Blend behavious and Markup extensions,
to me the most interesting 😉

Just a helpfull example: ContentMargin attached property (thanks to Steven Hollidge). 😉

source: Extending XAML To Overcome Pretty Much Any Limitation

Technorati tags: XAML, Blend
Advertisements

Advanced MVVM

October 21, 2012

Advanced MVVM by Josh Smith

Amazon:

This e-book is for WPF and Silverlight developers looking to take their Model-View-ViewModel skills to the next level. It reviews how the MVVM design pattern was used to create a fun and addictive game that provides an elegant user experience. Read this e-book to gain insights from Josh Smith, an industry recognized expert in WPF, Silverlight, and MVVM, on how to properly design complex View and ViewModel architectures. Learn how to support unlimited undo, coordinate animated transitions, control modal dialog boxes from a ViewModel, and much more.

Me: I read this book a long ago, when I started writing WPF+MVVM apps. It was helpfull that time, and for WPF/SL+MVVM beginners it’s still husefull.
In your early steps in MVVM, better read it.
It’s less da 60 pages and it’s a very good example about developing a MVVM application.
😉

source: Advanced MVVM

Technorati tags: WPF,Silverlight,MVVM

Bing Maps: draw circle on map

March 12, 2011

Working with maps, ie Bing Maps, you may need to draw figures, pologones (rectangles, circles, ecc) on your map to show area boundaries.
The simples poligones you need are: squares, rectangles, circles.
Of course, the poligone you draw have to follow map’s zoom, and you don’t want to re-draw it every zoom action 😦

Last one, the circle, is intuitive when you need a short look to something in the nearby (10 km radius from Chris Pietschmannxyz).
Chris Pietschmann has a sample that clears your mind, for the simplest solution you’ve never thinked about: pushpins. 😉

In his post, Silverlight Bing Maps: Draw Circle Around a Latitude/Longitude Location, he shows you how to get the circle perimeter ()

source: Silverlight Bing Maps: Draw Circle Around a Latitude/Longitude Location

Technorati Tags: , 

Checkbox: where is Wrap ?

January 8, 2011

CheckBox doesn’t have Wrap Property for Content Property…
because Content is an object type (did it remember you anything similar?)
😦

What if Content has short text ?
Here is an example, some controls in a grid.

  <CheckBox Content="check"
            Grid.Row="1" Grid.Column="0"
            />

And what is Content has a longer text ? ;(

  <CheckBox Content="check this bla bla bla bla"
            Grid.Row="1" Grid.Column="0"
            />

The solution: custom Content, of course!

Here is a very simple example. 🙂

  <CheckBox Grid.Row="1" Grid.Column="0">
            <TextBox Text="check this bla bla bla bla" 
					TextWrapping="Wrap" 
					BorderThickness="0"
					/>
  </CheckBox>

source: How to make the text of a CheckBox wrap across multiple lines

Technorati Tags: ,,,.

Tooltip: Multibinding failed because it has no valid converter

December 31, 2010

Maybe you forgot it everytime ToolTip is more than a simple text.

Here is an example of a simple TextBlock control:

  <TextBlock Text="{Binding Path=Person.NameSurname}" 
        ToolTip="{Binding Path=Persona.LocalAddress}" />

What would you do if you want have a reacher ToolTip…person’s mobile phone number too?

Well you can’t simply have something like this 😦

  <TextBlock Text="{Binding Path=Person.NameSurname}">
      <TextBlock.ToolTip>
        <Multibinding StringFormat="{}{0} - m. {1}">
              <Binding Path="Person.LocalAddress" />
              <Binding Path="Person.Mobile" />
        </Multibinding>    
      </TextBlock.ToolTip>  
  </TextBlock>

You get the error “Multibinding failed because it has no valid converter”.
Why?
Compare Text vs ToolTip MSDN page in TextBlock control …
you got it ?!?
Text is a String, ToolTip is an object, straight from FrameworkElement!

So you can define a style for it, a template, or something simpler … like this 😉

  <TextBlock Text="{Binding Path=Person.NameSurname}">
      <TextBlock.ToolTip>
          <TextBlock>
              <TextBlock.Text>
                  <Multibinding StringFormat="{}{0} - m. {1}">
                      <Binding Path="Person.LocalAddress" />
                      <Binding Path="Person.Mobile" />
                  </Multibinding>    
              </TextBlock.ToolTip>  
          </TextBlock>
      </TextBlock.ToolTip>
  </TextBlock>

Easier, ain’t it? 🙂

Technorati Tags: ,,,.