Upgrading a Windows 8.0 component to Windows 8.1 and Windows Phone 8.1 (WinRT)


Last year, I have created a carousel control, to show how it’s easy to create a custom control in C# / Xaml within Windows 8.0 apps model.

For reminder purpose, here is the original post : http://blogs.msdn.com/b/mim/archive/2013/03/19/create-a-custom-user-control-using-xaml-and-c-for-windows-8.aspx


With the availability of WinRT on Windows Phone 8.1, I have deciced to migrate my control to Windows Phone 8.1

Existing Solution

Here is the existing solution :


Yes, you are right … Only 1 project ! I assume it would have been better to have two projects : One for my custom control and one for my Ui sample (OBVIOUS ! ) …
We will correct this architecture mistake in the new solution Sourire

New Solution

For the new solution, I’ve deciced to create a Portable Class Library for Universals project for my custom control.

By the way, i didn’t use the Shared Folder feature of Universals Apps, because I maybe want to distribute my custom control in its own assembly. Shared project is just about sharing code, compiled within each application.


Here we go :


After a copy – paste from the last solution to the new solution, a compilation on each plateform raised an error, du to some projection compliance with IEnumerable<T> or IList<T> (from my property DataSource)

Error on Windows Phone 8.1 :


Error on Windows 8.1 :


Some Informations about it :


Like ItemsSource on ItemsControl, I just changed my property from IEnumerable<T> to … Object :


Here is the only code I have changed :

1 /// <summary> 2 /// Items source : Better if ObservableCollection 🙂 3 /// </summary> 4 public IEnumerable<Object> ItemsSource 5 { 6 get { return (IEnumerable<Object>)GetValue(ItemsSourceProperty); } 7 set { SetValue(ItemsSourceProperty, value); } 8 } 9 10 // Using a DependencyProperty as the backing store for ItemsSource. 11 //This enables animation, styling, binding, etc... 12 public static readonly DependencyProperty ItemsSourceProperty = 13 DependencyProperty.Register("ItemsSource", 14 typeof(IEnumerable<Object>), 15 typeof(LightStone), 16 new PropertyMetadata(0, ItemsSourceChangedCallback));

Here is some screenshots of the control on Windows Phone 8.1 and Windows 8.1






Project sources : http://www.dotmim.com/sitefiles/LightStoneWinRT.zip

Comments (0)