Showing posts with label Windows Phone. Show all posts
Showing posts with label Windows Phone. Show all posts

Monday, February 9, 2015

How to use Windows Phone Appbar using Cimbalino.Toolkit with Panorama control

My brief story of two application bar implementations... 


I love AppBarUtils, no doubt! There's so much love in that package and I have used it in several of my windows phone projects. But I wanted to try out something else that has the same or more features... and I know one thing for sure... AppBarUtils has a bug (at least that's what I found out). I cannot bind the IsEnabled property especially if I have different panorama item to display different appbar buttons and menus.. After some googling around, there are developers who faced the same problem as I did too... one of them advice to try out Cimbalino Windows Phone Toolkit. So my adventure begins..

Here comes Cimbalino Windows Phone Toolkit!

So far it has 15,578 downloads as of this blog posting, compared with AppBarUtils which has 8,682 downloads... Hmmm..!

Bugs aside, I'm not going to write about the bug here. What I want to share is the fact that the way Cimbalino Appbar works a bit different from the AppBarUtils counterpart, and there aren't a lot of examples to follow, hence I did some digging myself...

Just like the AppBarUtils approach, I wanted my Panorama view to have different application bars based on different PanoramaItem selected.

With AppBarUtils, it is already supported in xaml. But for Cimbalino, I have to dig in to find out more about it.

Cimbalino Toolkit has two appbar variants - the ApplicationBarBehavior and MultiApplicationBarBehavior. Both sits in the Cimbalino.Phone.Toolkit.Behaviors namespace. The one I'm interested at is the MultiApplicationBarBehavior as I already know what ApplicationBarBehavior is and how to implement it.

MultiApplicationBarBehavior control has a property called SelectedIndex. It is a dependency property and hence, easy to bind to our viewmodel.


Looking a bit more at the implementation, I found out that there's an internal property called SelectedItem. What this code does is that it gets the int value of the SelectedIndex (which we can bind it in our viewmodel) and then set's the correct ApplicationBar based on it.. nice! Ok, so far I know that SelectedIndex is bindable, and the rest of the code in SelectedItem might lead me to more clues.... (being lazy at looking at Cimbalino's source code though)



In WinPhone's Panorama control... there's an event called SelectionChanged.

If the selection of the PanoramaItem is changed by the user, this event will be triggered..
I think I have enough information to implement this.. so here goes. By the way, I assume you already know MVVM pattern, and any decent MVVM frameworks such as GalaSoft's or others. All in all, what's most important is that you understand the use of INotifyPropertyChanged interface for your viewmodel.

The View and the ViewModel

I have a simple binding property called SelectedIndex.














This property will be binded to the MultiApplicationBarBehavior.SelectedIndex property...

and the final result:








Of course, We can further improve this implementation, but that's for you to find out more..

That's it!

Enjoy!



Sunday, July 20, 2014

The 'ProductID' attribute is invalid - http://WPCommontypesST_Guid

Recently I found something that might be a bug when creating cross platform projects using Xamarin.Forms.

The error exists in the Windows Phone 8 Silverlight project and does not exists in the Android nor the iOS projects. 

After project creation is completed, go ahead and build the entire solution (or in this case just the Windows Phone project). Potentially you'll get the error as below:



Because of this, you won't be able to compile the windows phone project at all.. sad! 
All is not lost, the good thing is that it is easy to fix! 
What you need to do is this..

Navigate to the Windows Phone 8.0 project and expand Properties. You will see several files on that section and one of them is WMAppManifest.xml file.


Next, double click on that file. You'll get this.


click the link "View manifest in XML editor" and choose "Yes" when the dialog popups up.



Find the the section ProductID and PublisherID.
It should look something like this in the xml:-


Now, what you need to do is put in open and close curly brackets for both ProductID and PublisherID






Save, the file, and close it. Double click on the WMAppManifest.xml file again. You will get this


Compile the project. The error is gone :)


I am not sure if this is a fix for it, but it does work in my case. 
I am happy!  :)


Happy coding!

Saturday, March 29, 2014

Why I chose Windows Phone development for my next big thing...

Why I chose Windows Phone development for my next big thing...

people asked me. My answer is why not? Then they go wining around saying that many softwares comes from Microsoft are crap. Complex software license, damn pricey, and for friends that comes from development background, some say Visual Studio sucks. Its funny though, since almost 80% of my developer friends use Visual Studio day in, day out.

Then I wondered, if Windows sucks, and Visual Studio is buggy, then why are you using it in your day to day work? Why don't you use other platforms... ?! Stop wining peeps! There are always choices out there to choose from. Don't like it? Then switch and move on. No one is forcing you...

Windows is buggy - that I acknowledge, but that was then. I think Windows has come a long way till now. XP was a great product, but Vista wasn't. Win7 is awesome. Win8? Well, it is better in many ways, and not in others. Radical changes especially with the new "Modern UI" language. Its good to see a lot of changes in the new OS, especially moving away from the desktop environment. But too radical isn't good either. On the other hand, unifying the OS platform to become one is a big step ahead and a huge challenge. Something that IOS has accomplished very well several years ago.. - kudos Apple!

Windows Phone is unique. There's no icon to represent apps - Well, the tiles are the "icons". It is different. It lives on top of a concept called Live Tiles. Which I think is a fun to see when those live tiles flips to give me latest information without having to launch an app - It's ALIVE!!!

I know android has something called widgets, but I like live tiles better.

So again, why Windows Phone development? For simple fact is because, I can use C# and xaml to write apps on it. Since I already know WPF and Silverlight, it makes perfect sense to me to jump to Windows Phone app development. Hence, the learning curve was not so steep. MVVM can be applied in almost the same manner as WPF and Silverlight - with some distinctness which I'm not going to talk about here.

The only thing that needs some learning is understanding the wp's application lifecycle, frames and pages, navigation and non linear navigation, transition behaviors from a page to another, backstacks, and so forth. Sounds like its a lot to learn right? Actually it isn't at all. Of course there are some limitations to Windows Phone xaml technology. It doesn't have the power of WPF, but hey, I could create an app with less time. That helps you know...

So my journey started in November 2013. It was the time where I got serious with win phone app development. I joined Nokia's win phone developer's program, and got a year worth of Telerik RadControls for Windows Phone, plus a year worth of Windows Phone Store app account to publish apps. All is good right? No, you need to have a device to test run your app.

Worth mentioning I got myself a Nokia Lumia 920. Proudly to say during that time, I ordered prior to the Nokia Lumia 920 launch in Malaysia!!


Its a piece of awesome device I would say, and I love using it everyday...

From Nov 2013 till now - March 2014, that's like 4 months. I've learned many things in developing an app. Proudly to say, my first test app called Peek-a-boo is already in trial phase at 0.5.0.0. 

Now, I'm coding a new app as well, called Memorizer. More on Memorizer in my future blog post.

In short, within four months of playing around with win phone dev, I've already made a lot of progress. It's only time when I can publish my apps... 


p/s: Apart from Peek-a-boo and Memorizer, I've outlined like 3 or 4 more in the pipeline... 



Full Steam Ahead!