by LHayes01
2. February 2011 18:33
Windows Phone 7 MUST HAVE Toolkits
Another MUST HAVE post, but it’s well worth the read.

by LHayes01
22. January 2011 17:36
by LHayes01
22. January 2011 09:34
by LHayes01
20. January 2011 10:15
Recently a colleague of mine pointed out to me that visibility properties should not really belong in your view models.
What’s the alternative?
Use bool properties in your VM and converter.
Firstly the converter.
1 public class BoolToVisibilityConverter : IValueConverter
2 {
3
4 public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
5 {
6 if (value.GetType() == typeof(bool))
7 {
8 if ((bool)value == true)
9 {
10 return Visibility.Visible;
11 }
12 else
13 {
14 return Visibility.Collapsed;
15 }
16 }
17 return null;
18 }
19
20 public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
21 {
22 throw new NotImplementedException();
23 }
24 }
Secondly, register the converter in your XAML
1 xmlns:converters="clr-namespace:myApp.Converters;assembly=myApp"
2
3 <UserControl.Resources>
4 <converters:BoolToVisibilityConverter x:Key="BoolToVisibilityConverter"/>
5 </UserControl.Resources>
6
And thirdly, use the converter in the binding statement
1 Visibility="{Binding CommandButtonsVisibility, Converter={StaticResource BoolToVisibilityConverter}}"
by LHayes01
11. January 2011 09:48
Link to blog posting(Fear and Loathing, the technical blog of Bil Simser)

by LHayes01
10. January 2011 11:07
Why use the DataStateBehaviour?
The DataStateBehaviour lets you change the look and feel of your XAML at runtime with the Visual States Manager in a very MVVM friendly way – best of both worlds.
Create a property (MenuIsVisible) in your view model and then you can bind the desired states in the xaml.
Binding="{Binding MenuIsVisible}" TrueState="ShowMenu" FalseState="None" Value="True"
Simple example code :
XAML
1 <UserControl
2 x:Class="DataStateDemo.MainPage"
3 xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
4 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
5 xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
6 xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
7 mc:Ignorable="d"
8 d:DesignHeight="100" d:DesignWidth="200"
9 xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
10 xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
11 >
12
13 <Grid x:Name="LayoutRoot" Background="White">
14
15 <VisualStateManager.CustomVisualStateManager>
16 <ei:ExtendedVisualStateManager/>
17 </VisualStateManager.CustomVisualStateManager>
18
19 <i:Interaction.Behaviors>
20 <ei:DataStateBehavior Binding="{Binding MenuIsVisible}" TrueState="ShowMenu" FalseState="None" Value="True"/>
21 </i:Interaction.Behaviors>
22
23 <VisualStateManager.VisualStateGroups>
24 <VisualStateGroup x:Name="MenuStates">
25 <VisualState x:Name="None"/>
26 <VisualState x:Name="ShowMenu">
27 <Storyboard>
28 <ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.Visibility)" Storyboard.TargetName="gridMenu">
29 <DiscreteObjectKeyFrame KeyTime="0">
30 <DiscreteObjectKeyFrame.Value>
31 <Visibility>Visible</Visibility>
32 </DiscreteObjectKeyFrame.Value>
33 </DiscreteObjectKeyFrame>
34 </ObjectAnimationUsingKeyFrames>
35 </Storyboard>
36 </VisualState>
37 </VisualStateGroup>
38 </VisualStateManager.VisualStateGroups>
39
40 <Button Command="{Binding ShowMenuCommand}" Height="20" Width="150" HorizontalAlignment="Center" VerticalAlignment="Top">Show Menu</Button>
41
42 <Grid x:Name="gridMenu" Visibility="Collapsed" Height="50" Width="150">
43 <StackPanel>
44 <TextBlock>First Menu Item</TextBlock>
45 <TextBlock>Second Menu Item</TextBlock>
46 </StackPanel>
47 </Grid>
48
49 </Grid>
50 </UserControl>
Code Behind
1 using System.Windows.Controls;
2
3 namespace DataStateDemo
4 {
5 public partial class MainPage : UserControl
6 {
7 public MainPage()
8 {
9 InitializeComponent();
10 Loaded += (s, e) =>
11 {
12 DataContext = new MainPageViewModel();
13 };
14 }
15 }
16 }
View Model
1 using System;
2 using System.Linq.Expressions;
3 using System.Windows.Input;
4 using GalaSoft.MvvmLight;
5 using GalaSoft.MvvmLight.Command;
6
7 namespace DataStateDemo
8 {
9 public class MainPageViewModel : ViewModelBase
10 {
11 public ICommand ShowMenuCommand { get; private set; }
12
13 private bool menuIsVisible;
14
15 public MainPageViewModel()
16 {
17 ShowMenuCommand = new RelayCommand(() => { MenuIsVisible = !MenuIsVisible; });
18 }
19
20 public bool MenuIsVisible
21 {
22 get { return menuIsVisible; }
23 set
24 {
25 menuIsVisible = value;
26 RaisePropertyChanged(() => MenuIsVisible);
27 }
28 }
29
30 #region INotifyPropertyChanged
31
32 protected void RaisePropertyChanged<T>(Expression<Func<T>> propertyAccessor)
33 {
34 MemberExpression member = (MemberExpression)propertyAccessor.Body;
35 RaisePropertyChanged(member.Member.Name);
36 }
37
38 #endregion
39 }
40 }
by LHayes01
5. January 2011 15:59
18c80b9f-a0c5-403b-a496-6b414713e508|1|5.0
Tags:
by LHayes01
24. December 2010 11:28
Wishing you a very Merry Christmas and a Happy New Year 2011.

d88a61e3-5c07-4623-838a-e3267eb5caf5|0|.0
Tags:
by LHayes01
23. December 2010 12:30
If you have one of these fantastic Windows phones, there are 2 accessories you must get.
1) JVC HA-FXC50-B High Quality In-Ear Canal Headphones – Black
http://www.amazon.co.uk/gp/product/B001NS62PA/ref=oss_product
2) Griffin SmartTalk Headphone Adapter and Control Mic For iPhone and Mobile Phones
http://www.amazon.co.uk/gp/product/B001C0LBEG/ref=oss_product
The headphones give you a great sound and real bass plus the SmartTalk creates a long lead and the ability to change music tracks without having to pickup the phone, open plan office based developer heaven!
Thanks for @RobFe for both recommendations.

9d9e7a43-48a0-4d2c-9baf-08b1b17c2af1|0|.0
Tags:
by LHayes01
16. December 2010 14:43
This one is a life saver, Shift-ALT-L to locate the current file in the Solution Explorer Tree.

by LHayes01
15. September 2010 16:37
da23982f-360e-420e-ae63-d87de15e0d22|0|.0
Tags:
by LHayes01
15. September 2010 16:34
Old one this but still good.
devenv.exe /nosplash
Faster start up for VS2010.
9400a659-c1a6-4e5e-8aaa-4b8d916f1a47|0|.0
Tags: VS2010
VS2010
by LHayes01
31. August 2010 22:24
I’ve managed to wrestle control of my blog back from the hackers and spammers, I should be blogging again real soon!
Thanks for the support.

6bf79fa4-0d6d-4b1a-8870-25b7a93c680d|0|.0
Tags:
by LeeRoystonHayes
28. July 2010 14:11
6c9abc86-a2bd-4635-ada8-a4ce1306f8fc|0|.0
Tags: VS2010
VS2010
by LeeRoystonHayes
19. July 2010 09:53
by LeeRoystonHayes
1. July 2010 14:45
In the editor Ctrl-I to change to incremental search mode.
The cursor changes to a pair of Binoculars with a green arrow and the status bar displays “Incremental Search”.
Start Typing and the first match is highlighted, Ctrl-I again to move to the next match, Ctrl-Shift-I to move back.
Escape to return to normal mode.

75e39611-b6b2-477f-a326-957a767debb6|0|.0
Tags:
by LeeRoystonHayes
1. July 2010 14:22
Copy “A” (Ctrl-C), copy “B” (Ctrl-C), copy “C” (Ctrl-C).
Ctrl-Shift-V once to paste “A”, twice to past “B” and three times to paste “C”!
d37c0ea3-f00f-407c-8ef2-6e44b8dbeef6|0|.0
Tags: VS2010
VS2010
by LeeRoystonHayes
28. June 2010 15:08
Here is my take on the really useful bits in order.
- MEF
- ICommand Support
- Right Click Menus
- Text trimming / formatting, Null Values and Fallback Value.
- Out of Browser
- Printing API
- Dependency binding
- Microphone and Webcam support
There and many many more improvements, not least the re-write of the XAML parser, but these are the most useful to me in the field. I hope to in the next few days do a look at each one and produce a sample with each.
d56f4046-f924-4710-829f-de88d1c63e27|0|.0
Tags:
by LeeRoystonHayes
23. June 2010 09:17
A little off topic this one, but if like me you love food this website is great.
http://www.bbc.co.uk/food/recipes/
48339d27-f870-49eb-9376-1f2a65ef743e|0|.0
Tags:
by LeeRoystonHayes
21. May 2010 09:27
Here is a brief summary review of the important points.
1) MVVM-C, Model-View-ViewModel-Controller.
To keep ViewModel light and small consider introducing a controller per VM that sits behind and performs all the service access and business logic. Why? To make the VM smaller and lighter and also perform service access in a background worker thread and marshal the results to the UI thread (VM) at the last possible moment.
This makes perfect sense to me and I have experienced VM bloat. Ray Booysen who gave the talk is a Silverlight programmer in the financial services sector and specialises in low latency systems.
2) Use the enableRedrawRegions and enableFrameRateCounter options.
By enabling these two options, it becomes very clear where you interface is redrawing during operation and avoiding the drop shadow effect is a must (this redraws the entire control and ever other control in the visual tree following).
3) Debugging and the SOS dll.
4) Unit Testing
The Silverlight Unit testing framework runs on the full .net stack (not the SL stack) and tests that pass in the unit tests may fail in SL.
http://edgeug.net/
by LeeRoystonHayes
18. May 2010 14:57
Control + Tab bring up the VS2010 navigator, Control + Tab again to move forward through the items.
Control + Shift + Tab, move back through the items.

66b6b622-4378-42aa-92fc-0f4e91d8b43b|0|.0
Tags: VS2010
VS2010
by LeeRoystonHayes
17. May 2010 09:38
by LeeRoystonHayes
14. May 2010 16:35
Today I have published my first Silverlight behaviour to the expression blend gallery.
http://gallery.expression.microsoft.com/en-us/ShowHideWithFlip
Please vote for me!

by LeeRoystonHayes
14. May 2010 14:03
Did you know VS2010 comes with a library of icons, png’s, and bitmaps?
Navigate to :
C:\Program Files (x86)\Microsoft Visual Studio 10.0\Common7\VS2010ImageLibrary\1033 (Win 64)
or
C:\Program Files\Microsoft Visual Studio 10.0\Common7\VS2010ImageLibrary\1033 (Win 32)
and find file VS2010ImageLibrary.zip.
a9ef08b5-49be-4ddd-b438-04987e5b4d20|0|.0
Tags: VS2010
VS2010
by LeeRoystonHayes
14. May 2010 09:21
Right click your project and select “Calculate Code Metrics”.
I’m looking for a good detailed explanation of exactly what the metrics are so if you have any good links please email them to me and I will re-post here.


by LeeRoystonHayes
7. May 2010 09:10
One place to manage all the extensions in the VS2010 IDE.

Click the “online gallery” tab to see many more options to download.

2481d9f7-04c0-4086-88ac-e64d00f787b2|0|.0
Tags: VS2010
VS2010
by LeeRoystonHayes
5. May 2010 09:29
To take advantage of the multi core’s in your servers and desktops .net 4 has many multi thread programming extensions.
“Parallel.ForEach” is one such extension, and the gottcha?
The loop is not always processed in the same order.
In this simple example the list of names comes out in a different order each time.

by LeeRoystonHayes
30. April 2010 10:03
Named optional parameters with default values new in c# 4.0!


by LeeRoystonHayes
29. April 2010 13:14
You can now “pin” a project in the Recent Projects list on the start page to keep your live work at the top. Hover over the area to the left of the project name and click to pin and un-pin.

by LeeRoystonHayes
29. April 2010 09:17
You can dislocate panels from the VS2010 IDE and float them over to another monitor. Click and drag from the tab bar and you window is free!
