Derik Whittaker

Syndication

News


Using the ToggleSwitch in WinRT/Metro (for C#)

On of the new user controls which is being released with WinRT/Metro is the ToggleSwitch which can be found in the Windows.UI.Xaml.Controls namespace.

When rendered the control looks like below. 

image

By looking at the above you can see 3 distinct data points.

  1. The header (value of Font Size) – Header=”Font Size”
  2. The off/on content (value of small) – OffContent=”Small” or OnContent=”Large”
  3. The value of the actual toggle (off in above) – IsOn={Binding IsLightSelected, Mode=TwoWay}

When you use this control you have the ability of course to either hard wire your values for Header/On/Off or you can use Binding (aka MvvM) to set them.  Also If you want to know the selected state you will want to pay attention to the IsOn property, which of course you can bind to (make sure you enable it as TwoWay binding as show above).

Of course you can make other changes to this control via XAML (or code behind).  These changes include setting the FlowDirection and the OffContentTemplate/OnContentTemplate which allows you to change the layout/look and feel.

This is a pretty nice UI control and as you can see if pretty simple to use.

Till next time,


Posted 10-25-2011 6:21 PM by Derik Whittaker
Filed under: , ,

[Advertisement]

Comments

ratnesh wrote re: Using the ToggleSwitch in WinRT/Metro (for C#)
on 12-07-2011 1:06 PM

hi,

i am preparing for mcts 70-536(c#) .please provide me sample question of test.

About The CodeBetter.Com Blog Network
CodeBetter.Com FAQ

Our Mission

Advertisers should contact Brendan

Subscribe
Google Reader or Homepage

del.icio.us CodeBetter.com Latest Items
Add to My Yahoo!
Subscribe with Bloglines
Subscribe in NewsGator Online
Subscribe with myFeedster
Add to My AOL
Furl CodeBetter.com Latest Items
Subscribe in Rojo

Member Projects
DimeCasts.Net - Derik Whittaker

Friends of Devlicio.us
Red-Gate Tools For SQL and .NET

NDepend

SlickEdit
 
SmartInspect .NET Logging
NGEDIT: ViEmu and Codekana
LiteAccounting.Com
DevExpress
Fixx
NHibernate Profiler
Unfuddle
Balsamiq Mockups
Scrumy
JetBrains - ReSharper
Umbraco
NServiceBus
RavenDb
Web Sequence Diagrams
Ducksboard<-- NEW Friend!

 



Site Copyright © 2007 CodeBetter.Com
Content Copyright Individual Bloggers

 

Community Server (Commercial Edition)