With the recent reports of smartphone market share beginning to pour in, Kantar Worldpanel data reports tremendous growth year over year (YoY) for Windows Phone 8. From last April until this April, Windows Phone has increased it's footprint by nearly 50%. It has reached nearly 7% market penetration on Verizon and this is without the highly lauded Lumia 928, which just recently became available.
Even more surprising is the numbers coming over from Europe. Windows Phone 8 has exceeded 10% market share in Italy and is fast approaching that number in the Great Britain market. Only Android has consistently outpaced Windows in growth. As you look at the percentages, Android's gains are relatively small compared to Windows. iOS percentage continues to decline in half of the markets.
Blackberry has lost share in all the markets. Even with the new launch of BB10, their shares continue to erode. I anticipate that Blackberry will be gone within the next 12-24 months. Unless they find a way to maintain profitability with their government contracts, it looks like this market is quickly becoming a trio-poly.
If you follow the Windows go to market strategy even further, Nokia and Microsoft have been pushing out lower end devices at really bargain prices. Most people don't know this: Android's market dominance has more to do with the low end, rental phones and cheap phones than the $640 Samsung Galaxy 3 and 4.
As people's 2 year contacts continue to expire, more and more people will jump ship and pick up a new Windows Phone. And after seeing some of the leaked shots of iOS 7, I expect that update will greatly disappoint many Apple fanboys, while Android is still struggling to get past it's anemic updates to Jelly Bean.
Couple that with the newly released 928 on Verizon and the stunning 925 on T-Mobile, Microsoft's shares will continue to climb and take over the #2 spot in many more markets in the coming months and years.
John Humenik's Personal Blog
Search
Tuesday, June 4, 2013
Tuesday, May 28, 2013
Xbox One
I remember the first day that I got my Xbox 360. I remember longing for the days of playing HD games without having to constantly upgrade my PC with expensive graphical cards and the latest CPUs. The gaming consoles long solved that problem by packing in tons of power into a little box. The 360 was no different.
It has twice the memory of the PlayStation 3. It had HD graphics, while the Wii did not. I was completely blown away by the quality and theater sound you could get out of this little machine that cost less than $400. I remember that day very well. What I also remember was...it should've included a TV capture card so Windows Media Center could be your DVR.
Fast forward till today. While there's no explicit mention that the Xbox One would have DVR functionality, what was clear it was taking the next major step at controlling your family room entertainment. You have voice controlled functions powered by the Kinect 2. Turn on your Xbox by saying "Xbox on", switch channels by speaking their name. Accept Skype calls and watch TV at the same time. Finally picture in picture that makes sense.
The Xbox One will clearly change how we watch and enjoy TV, play games and interact with one another. Some of the amazing new features is game pausing and picking it up where you left off, even if you are picking up the play from your friend's house. You can record your games, maybe even share those experiences on Vine or Facebook.
Kinect 2 can detect your heart rate. Yes, it can even tell if you are working too hard and let you know if you need to slow down. It can detect wrist movements and more granular motions and movements. An improved voice recognition system that can learn and detect multiple people's voices at the same time. You can play in a smaller area (Yes!) and with up to six people. You have HD video capture on multiple visible and invisible light waves.
The Xbox One doesn't stop there. It has a fully working version of Windows 8 on it. Microsoft has longed to set this up. They have a single host operating system that runs the Xbox system, Windows and another system that talks to both. What does this mean for the non-geeks out there? It means that you can play games, interact with Win 8 apps and do them at the same time. Its two gaming environments packed into 'One' box.
Add in Blu-Ray support, cloud supported gaming, where the 300,000 Microsoft servers process heavy tasks so your Xbox One doesn't have to, upward support for 3D, 4K video and much more. Tack on IllumaRoom and the possibility of augmented reality glasses and we've got the Star Trek holodeck in the year 2013!
It has twice the memory of the PlayStation 3. It had HD graphics, while the Wii did not. I was completely blown away by the quality and theater sound you could get out of this little machine that cost less than $400. I remember that day very well. What I also remember was...it should've included a TV capture card so Windows Media Center could be your DVR.
Fast forward till today. While there's no explicit mention that the Xbox One would have DVR functionality, what was clear it was taking the next major step at controlling your family room entertainment. You have voice controlled functions powered by the Kinect 2. Turn on your Xbox by saying "Xbox on", switch channels by speaking their name. Accept Skype calls and watch TV at the same time. Finally picture in picture that makes sense.
The Xbox One will clearly change how we watch and enjoy TV, play games and interact with one another. Some of the amazing new features is game pausing and picking it up where you left off, even if you are picking up the play from your friend's house. You can record your games, maybe even share those experiences on Vine or Facebook.
Kinect 2 can detect your heart rate. Yes, it can even tell if you are working too hard and let you know if you need to slow down. It can detect wrist movements and more granular motions and movements. An improved voice recognition system that can learn and detect multiple people's voices at the same time. You can play in a smaller area (Yes!) and with up to six people. You have HD video capture on multiple visible and invisible light waves.
The Xbox One doesn't stop there. It has a fully working version of Windows 8 on it. Microsoft has longed to set this up. They have a single host operating system that runs the Xbox system, Windows and another system that talks to both. What does this mean for the non-geeks out there? It means that you can play games, interact with Win 8 apps and do them at the same time. Its two gaming environments packed into 'One' box.
Add in Blu-Ray support, cloud supported gaming, where the 300,000 Microsoft servers process heavy tasks so your Xbox One doesn't have to, upward support for 3D, 4K video and much more. Tack on IllumaRoom and the possibility of augmented reality glasses and we've got the Star Trek holodeck in the year 2013!
Friday, May 3, 2013
Windows Phone 8 and Windows 8 sales surge in Q1 2013
With the first quarter sales coming out, there happens to be a lot of good news for the Softies from Redmond. IDC has been reporting that Windows Phone 8 has outsold iPhone in 7 markets and have reached the “critical 10% in multiple markets” and continue to gain ground on both Android and iPhone in the all-important US market.
While there are a lot of various reports, Gartner, Kantar, IDC, etc. they all show a common theme. Windows Phone 8 has grown on average by 20% YoY (Year over Year). iPhone sales are flat to declining, Android has shown all three (declining, flat and slightly growing %’s) and Blackberry falling off the planet.
Verizon will be launching the Nokia’s flagship 928 in the coming weeks. T-Mobile will be following suit with their own variant. Nokia has the lion’s share of the Windows Phone 8 market, hovering around 80—85%. HTC has second place with a double-digit share with everyone else in the low singles.
You can expect Windows Phone 8 to continue their steady climb up. Many analysts expect they should have 20% share by the end of 2014. At the pace they are climbing this seems a very realistic goal.
Looking over the aisle to Windows 8, the Surface Pro continues to amaze with its market penetration. Amazon Kindle took the world by storm around 18 months ago. Their sales were so impressive they came out with 4 new tablet variants last holiday season.
In the same 6 months, Microsoft Surface has gained nearly 50% on the Kindle. As Microsoft expands the Surface Pro sales into various markets, you can be rest assured that those sales will skyrocket.
Microsoft has been rumored to be looking at a 7” tablet and 5”+ Windows Phone. More profiles, more options and more markets will translate to deeper penetrations.
Intel spoke about tablets running their new processors will be around $200. If WinTel is able to pull off a $200-$300 tablet PC that runs Office 2013, touch/pen and has that awesome cover-keyboard, no competitor will have a solution to match.
While there are a lot of various reports, Gartner, Kantar, IDC, etc. they all show a common theme. Windows Phone 8 has grown on average by 20% YoY (Year over Year). iPhone sales are flat to declining, Android has shown all three (declining, flat and slightly growing %’s) and Blackberry falling off the planet.
Verizon will be launching the Nokia’s flagship 928 in the coming weeks. T-Mobile will be following suit with their own variant. Nokia has the lion’s share of the Windows Phone 8 market, hovering around 80—85%. HTC has second place with a double-digit share with everyone else in the low singles.
You can expect Windows Phone 8 to continue their steady climb up. Many analysts expect they should have 20% share by the end of 2014. At the pace they are climbing this seems a very realistic goal.
Looking over the aisle to Windows 8, the Surface Pro continues to amaze with its market penetration. Amazon Kindle took the world by storm around 18 months ago. Their sales were so impressive they came out with 4 new tablet variants last holiday season.
In the same 6 months, Microsoft Surface has gained nearly 50% on the Kindle. As Microsoft expands the Surface Pro sales into various markets, you can be rest assured that those sales will skyrocket.
Microsoft has been rumored to be looking at a 7” tablet and 5”+ Windows Phone. More profiles, more options and more markets will translate to deeper penetrations.
Intel spoke about tablets running their new processors will be around $200. If WinTel is able to pull off a $200-$300 tablet PC that runs Office 2013, touch/pen and has that awesome cover-keyboard, no competitor will have a solution to match.
Thursday, April 25, 2013
Brandon Saad deserves to win the NHL Rookie of the Year
The Calder Memorial Trophy is the annual award given to the NHL Rookie of the Year. It has a long history of illustrious winners including Alexander Ovechkin (over Sidney Crosby in 2006), Evgeni Malkin, Brandon’s teammate Patrick Kane and others.
This shortened NHL season has seen a strong crop of potential candidates for the award. While you can find out more information on those candidates, if I had a vote it would go to Blackhawks starting Left Winger, Brandon Saad.
Why? While Brandon stats speak for themselves: He's fourth on the Blackhawks in goals (10), fourth in assists (16), tied for fifth in plus/minus (+16). He’s only committed 6 penalties all season long. Sydney Crosby has committed 1 more penalty in 36 games compared to Brandon’s 45.
Brandon’s stats against other rookies are even better. He’s 5th in goals (only 4 behind #1), 2nd in assists (1 behind), 3rd in points (2 behind) and 1st in plus/minus.
Brandon’s success doesn’t stop there. He plays on the #1 line across Jonathon Toews and Marian Hossa on the #1 team in the NHL, the Blackhawks already won the President’s Trophy for most points in a season. He’s played there since game 1 and hasn’t lost his position.
For those who don’t play, watch or coach hockey my last paragraph wouldn’t make much sense. Let me take a moment to explain why “the last” paragraph alone should merit the award. When you play on the #1 line on the #1 team, you face every other teams “very best” players. You play against their elite defenseman, their shutdown forwards and the other teams #1 scoring line.
No coach in their right mind would put a rookie on the top line unless he whole-heartedly deserved to be there. Not only has Brandon earned his spot, he kept it, excelled at it and continues to be one the reasons the Blackhawks are the #1 team. Coaches are paid to win games. Hockey owners are notorious for firing coaches for sneezing in the wrong direction, there's no room for experiments or error.
When you put together your #1 line, you place your best players on that line. Chicago has a ton of elite talent. In addition to the #1 line, the roster has incredible forwards which include Patrick Kane, Viktor Stalberg, Bolland, Sharp to name a few. Through all of this, Brandon still plays on the #1 line.
My final comment on why Brandon Saad should win the Calder Trophy lies in the how the season’s progressed. Those who follow hockey know that every NHL player will tend to play their best hockey and give 110% towards the end of the season. The NHL Playoffs can end up being equivalent to 25% of the regular season and with 16 out of the 30 teams making the playoffs, the end rush is generally what matters.
Brandon has faced his opponents #1 talent during this mad rush to the end, while those players are playing their best. Through all that, he’s had a monster March with 15 points in 14 games. Look at the other Rookie of the Year candidates. Their numbers have dwindled, some plummeted, in March and April.
There’s a lot of reasons why Brandon Saad deserves to be Rookie of the Year. But when the game’s on the line and the season’s accolades are at stake, the Blackhawks kept Brandon at the tip of the spear and he delivered against the NHL's elite talent. None of the other rookies can say that.
http://espn.go.com/nhl/story/_/id/9248781/calder-finalists-top-nhl-rookie-montreal-canadiens-brendan-gallagher-florida-panthers-jonathan-huberdeau-chicago-blackhawks-brandon-saad
This shortened NHL season has seen a strong crop of potential candidates for the award. While you can find out more information on those candidates, if I had a vote it would go to Blackhawks starting Left Winger, Brandon Saad.
Why? While Brandon stats speak for themselves: He's fourth on the Blackhawks in goals (10), fourth in assists (16), tied for fifth in plus/minus (+16). He’s only committed 6 penalties all season long. Sydney Crosby has committed 1 more penalty in 36 games compared to Brandon’s 45.
Brandon’s stats against other rookies are even better. He’s 5th in goals (only 4 behind #1), 2nd in assists (1 behind), 3rd in points (2 behind) and 1st in plus/minus.
Brandon’s success doesn’t stop there. He plays on the #1 line across Jonathon Toews and Marian Hossa on the #1 team in the NHL, the Blackhawks already won the President’s Trophy for most points in a season. He’s played there since game 1 and hasn’t lost his position.
For those who don’t play, watch or coach hockey my last paragraph wouldn’t make much sense. Let me take a moment to explain why “the last” paragraph alone should merit the award. When you play on the #1 line on the #1 team, you face every other teams “very best” players. You play against their elite defenseman, their shutdown forwards and the other teams #1 scoring line.
No coach in their right mind would put a rookie on the top line unless he whole-heartedly deserved to be there. Not only has Brandon earned his spot, he kept it, excelled at it and continues to be one the reasons the Blackhawks are the #1 team. Coaches are paid to win games. Hockey owners are notorious for firing coaches for sneezing in the wrong direction, there's no room for experiments or error.
When you put together your #1 line, you place your best players on that line. Chicago has a ton of elite talent. In addition to the #1 line, the roster has incredible forwards which include Patrick Kane, Viktor Stalberg, Bolland, Sharp to name a few. Through all of this, Brandon still plays on the #1 line.
My final comment on why Brandon Saad should win the Calder Trophy lies in the how the season’s progressed. Those who follow hockey know that every NHL player will tend to play their best hockey and give 110% towards the end of the season. The NHL Playoffs can end up being equivalent to 25% of the regular season and with 16 out of the 30 teams making the playoffs, the end rush is generally what matters.
Brandon has faced his opponents #1 talent during this mad rush to the end, while those players are playing their best. Through all that, he’s had a monster March with 15 points in 14 games. Look at the other Rookie of the Year candidates. Their numbers have dwindled, some plummeted, in March and April.
There’s a lot of reasons why Brandon Saad deserves to be Rookie of the Year. But when the game’s on the line and the season’s accolades are at stake, the Blackhawks kept Brandon at the tip of the spear and he delivered against the NHL's elite talent. None of the other rookies can say that.
http://espn.go.com/nhl/story/_/id/9248781/calder-finalists-top-nhl-rookie-montreal-canadiens-brendan-gallagher-florida-panthers-jonathan-huberdeau-chicago-blackhawks-brandon-saad
Tuesday, April 16, 2013
Windows 8 WiFi connectivity issues
Read on if you are struggling with Windows 8 connectivity, here’s my story as
to how I fixed mine.
I’ve been playing around with Windows 8 since its first public release. While I was getting used to its schizophrenic (Metro and traditional desktop) interfaces, I noticed issues with my PC getting ‘Limited’ wireless connectivity. In addition to the limited connectivity issue, I started experiencing recurring USB, Bluetooth, Outlook (svchost.exe) and other connectivity problems.
Recently, it got so bad that I had to start intentionally blue screening my PC to free up the corrupt processes that were causing these issues to arise. Stopping and starting services, disabling and enabling devices and other tricks were employed to have it maintain connectivity.
Soon after that, Microsoft acknowledged and put out a fix for the ‘Limited’ connectivity problem. As soon as I could download it, I did. I noticed all my Bluetooth issues disappeared. To my chagrin, my wireless issues got worse. Before the fix, I could connect to wireless networks 30% of the time. Now it failed every time.
The svchost.exe process got worse and my PC became unusable until I went through my routine of disabling, enabling the devices and processes. I’ve proceeded back to the Internet and the forums and started going through these steps below.
1. Turned on "Download over metered connections"
2. Turned off all power management that I could find
3. Set maximum performance on wireless adapter in power settings
4. Ran through the network troubleshooter
5. WLAN Autoconfig is set to automatic
6. Verified that I have the latest drivers
7. I changed the driver from Microsoft to the manufacturer
8. Ran netsch winsock and netsch int ip
9. Disabled IP Helper
10. Disabled suspect applications in Task Manager’s Startup
In a stroke of luck, I read one article where a user uninstalled his corporate VPN client and it freed up his PC. At this point, I had nothing else to lose. I uninstalled the VPN client I had on my PC, rebooted and noticed that the wireless connected…automatically. I went to Device Manager and saw that all the devices that failed to load, successfully loaded.
I was shocked.
I rebooted, put the PC in sleep mode, restarted and it worked every time! My PC feels like a brand new computer now. Everything runs smoother and performs without a hitch.
Hopefully this article will help some other people experiencing the same problem. I was confident that MS had fixed the WiFi issue and my problem was environmental. For the first time ever, I’m able to use Win 8 as it was meant to be, an ultra-fast, ultra-responsive and rich OS that lives up to the billing.
I’ve been playing around with Windows 8 since its first public release. While I was getting used to its schizophrenic (Metro and traditional desktop) interfaces, I noticed issues with my PC getting ‘Limited’ wireless connectivity. In addition to the limited connectivity issue, I started experiencing recurring USB, Bluetooth, Outlook (svchost.exe) and other connectivity problems.
Recently, it got so bad that I had to start intentionally blue screening my PC to free up the corrupt processes that were causing these issues to arise. Stopping and starting services, disabling and enabling devices and other tricks were employed to have it maintain connectivity.
Soon after that, Microsoft acknowledged and put out a fix for the ‘Limited’ connectivity problem. As soon as I could download it, I did. I noticed all my Bluetooth issues disappeared. To my chagrin, my wireless issues got worse. Before the fix, I could connect to wireless networks 30% of the time. Now it failed every time.
The svchost.exe process got worse and my PC became unusable until I went through my routine of disabling, enabling the devices and processes. I’ve proceeded back to the Internet and the forums and started going through these steps below.
1. Turned on "Download over metered connections"
2. Turned off all power management that I could find
3. Set maximum performance on wireless adapter in power settings
4. Ran through the network troubleshooter
5. WLAN Autoconfig is set to automatic
6. Verified that I have the latest drivers
7. I changed the driver from Microsoft to the manufacturer
8. Ran netsch winsock and netsch int ip
9. Disabled IP Helper
10. Disabled suspect applications in Task Manager’s Startup
In a stroke of luck, I read one article where a user uninstalled his corporate VPN client and it freed up his PC. At this point, I had nothing else to lose. I uninstalled the VPN client I had on my PC, rebooted and noticed that the wireless connected…automatically. I went to Device Manager and saw that all the devices that failed to load, successfully loaded.
I was shocked.
I rebooted, put the PC in sleep mode, restarted and it worked every time! My PC feels like a brand new computer now. Everything runs smoother and performs without a hitch.
Hopefully this article will help some other people experiencing the same problem. I was confident that MS had fixed the WiFi issue and my problem was environmental. For the first time ever, I’m able to use Win 8 as it was meant to be, an ultra-fast, ultra-responsive and rich OS that lives up to the billing.
Tuesday, April 9, 2013
Create Beautiful Dynamic UI’s using DataTemplates and MVVM
In yesterday’s post, I talked about MVVM and how easy it is to start building composite applications leveraging this innovative programming paradigm. Until today, I was struggling with linking dynamically created UI elements to the view-model. To take it one step further, I wanted the user interface to be bound fully (Two-Way) to the view-model and be automatically updated as the view-model changes.
What’s an example? You have a view that prompts the user to input a count. That count could be used to create Albums, Contacts or whatever ‘class’ you want. Here’s the sample code for an Album.cs file:
You can add this code to your view-model class:
Update your view code with the XAML below, link your DataContext to your view-model and as you add new Album objects to your Albums observable collection, they will automatically show up on your UI and be bound to the view-model. Yes, it’s that simple to build rich UIs that are managed by user input at runtime.
What’s an example? You have a view that prompts the user to input a count. That count could be used to create Albums, Contacts or whatever ‘class’ you want. Here’s the sample code for an Album.cs file:
public class Album
{
public string Artist { get; set; }
public string Name { get; set; }
public string Year { get; set; }
}
You can add this code to your view-model class:
private ObservableCollection<Album> albums = new ObservableCollection<Album>();
public ObservableCollection<Album> Albums
{
get
{
return albums;
}
set
{
albums = value;
OnPropertyChanged("Albums");
}
}
Update your view code with the XAML below, link your DataContext to your view-model and as you add new Album objects to your Albums observable collection, they will automatically show up on your UI and be bound to the view-model. Yes, it’s that simple to build rich UIs that are managed by user input at runtime.
<ListBox Width="510"
ItemsSource="{Binding Path=Albums, Mode=TwoWay}" HorizontalContentAlignment="Stretch" BorderThickness="0">
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal" Margin="0,5,0,0">
<TextBlock Text="Artist:" Width="60" VerticalAlignment="Center"/>
<TextBox Text="{Binding Path=Artist}" Width="100"/>
<TextBlock Text="Name:" Width="60" Margin="5,0,0,0" VerticalAlignment="Center"/>
<TextBox Text="{Binding Path=Name}" Width="210" />
<TextBlock Text="Date:" Width="60" Margin="5,0,0,0" VerticalAlignment="Center"/>
<TextBox Text="{Binding Path=Date}" Width="50" /> <!--Normally
a date/year picker would be here-->
</StackPanel>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
Monday, April 8, 2013
Demystifying MVVM (Model View View-Model)
If are new to programming or haven’t used modern design and development patterns, MVVM could be a confusing acronym that makes no sense to you. If you are familiar with legacy design patterns (like MVC and MVP), the model view view-model may look a bit weird, although you’ll find it to be an excellent evolution to your current programming paradigm.
In layman’s terms the three areas are broken down with these definitions:
1. Model – The data, typically coming from a database, web service, file, or other source
2. View – The graphic user interface, such as a windows form or web screen
3. View Model – An abstraction layer that manipulates the data (model) so the screen (view) can display it. The view model will include other actions (methods/functions) that can save, edit and persist data.
The real power behind MVVM is the view model. The view model has OnPropertyChanged events that notify the listeners that data has changed and you should refresh your UI. Most view models are based upon a ViewModelBase class that has event handlers that are subscribed to and other methods that manage the low level state of the view model. I included a code snippet at the end of the article that I used in all my projects.
The view model is so powerful, you can reach the point where you have no code behind your view. You can have the view code (HTML, XAML, etc.), your view model (which can handle button click events, data bindings and data events like inserts, updates and selects) and your model. You can build test driven software that validates your assumptions and requirements without having a working application.
You can serve up mobile applications, web and thick client from the same infrastructure. The end result can be limitless. You can support iPhones, Android, Ubuntu, UNIX and Windows clients. Your development time can be dramatically reduced and your quality can be increased as well.
The best part there’s so many different programming technologies that support it. WPF and Silverlight inherently support it. JavaScript has a library known as Knockout that implements MVVM. You can leverage the Razor engine, standard ASP.NET, Ruby and so much more.
Look at MVVM and you’ll find a new paradigm in programming that’s easy, powerful and efficient. The best part, it’s light and doesn’t require a lot of infrastructure to make it work.
In layman’s terms the three areas are broken down with these definitions:
1. Model – The data, typically coming from a database, web service, file, or other source
2. View – The graphic user interface, such as a windows form or web screen
3. View Model – An abstraction layer that manipulates the data (model) so the screen (view) can display it. The view model will include other actions (methods/functions) that can save, edit and persist data.
The real power behind MVVM is the view model. The view model has OnPropertyChanged events that notify the listeners that data has changed and you should refresh your UI. Most view models are based upon a ViewModelBase class that has event handlers that are subscribed to and other methods that manage the low level state of the view model. I included a code snippet at the end of the article that I used in all my projects.
The view model is so powerful, you can reach the point where you have no code behind your view. You can have the view code (HTML, XAML, etc.), your view model (which can handle button click events, data bindings and data events like inserts, updates and selects) and your model. You can build test driven software that validates your assumptions and requirements without having a working application.
You can serve up mobile applications, web and thick client from the same infrastructure. The end result can be limitless. You can support iPhones, Android, Ubuntu, UNIX and Windows clients. Your development time can be dramatically reduced and your quality can be increased as well.
The best part there’s so many different programming technologies that support it. WPF and Silverlight inherently support it. JavaScript has a library known as Knockout that implements MVVM. You can leverage the Razor engine, standard ASP.NET, Ruby and so much more.
Look at MVVM and you’ll find a new paradigm in programming that’s easy, powerful and efficient. The best part, it’s light and doesn’t require a lot of infrastructure to make it work.
public class ViewModelBase
: INotifyPropertyChanged
{
/// <summary>
/// Set the ViewModelBase to throw exceptions
when property names are invalid
/// </summary>
private bool
throwOnInvalidPropertyName = true;
/// <summary>
/// Expose a property to override the base value
/// </summary>
protected bool ThrowOnInvalidPropertyName
{
get
{
return
throwOnInvalidPropertyName;
}
set
{
throwOnInvalidPropertyName = value;
}
}
/// <summary>
/// Setup an event to handle property changes
/// </summary>
public event
PropertyChangedEventHandler PropertyChanged;
/// <summary>
/// Verifies if the property is valid and raises
an event that its changed
/// </summary>
/// <param name="propertyName">Property that's
changed</param>
protected virtual void OnPropertyChanged(string
propertyName)
{
VerifyPropertyName(propertyName);
PropertyChangedEventHandler
handler = PropertyChanged;
if
(handler != null)
{
PropertyChangedEventArgs
e = new PropertyChangedEventArgs(propertyName);
handler(this, e);
}
}
/// <summary>
/// Verify that the property name matches a
real, public, instance property on this object
/// </summary>
/// <param name="propertyName">Property to check</param>
[Conditional("DEBUG")]
[DebuggerStepThrough]
public void VerifyPropertyName(string propertyName)
{
if
(TypeDescriptor.GetProperties(this)[propertyName]
== null)
{
string
message = "Invalid property name: "
+ propertyName;
if
(ThrowOnInvalidPropertyName)
throw new Exception(message);
else
Debug.Fail(message);
}
}
}
Subscribe to:
Posts (Atom)