Posts

Custom ComboBox control to defer current selection

I had this weird requirement in my project where: When I change the selection, new value should be sent to ViewModel, but the selection should not be changed until Success response comes back from a custom device attached to the application. i.e. If failure arrives then, combobox value will remain unchanged, and if success arrives then only ComboBox reflects the new value. Requirement was very unusual and that was not the functionality a built in combo-box supposed to do. So, I had to create a custom control with few hacks to make it work. Following is the code: public class ExtendedComboBox : ComboBox, ICommandSource { private bool _valueUpdatedFromUI; private int _previousIndex; private bool _dropDownClosed; private object _newlySelectedItem; #region DP /// <summary> /// Sends new value to ViewModel property /// </summary> public object DeferredSelectedItem { get { return (object)GetValue(DeferredSelectedItemProperty); }

Using Shared Components In Xamarin Forms

Image
Xamarin has several cross-platform libraries available for you to use so that we have unified API for accessing platform specific features from iOS, Windows Phone, and Android. These are all open source and available via GitHub which you can then use or modify to whatever you like. There are several components that Xamarin supports. The first is "Xamarin Social" which provides some social networking capabilities to your application. It has support for posting to Facebook and Twitter, to name a few. We also have Xamarin.Auth which is used for OAuth. It supports securely connecting to the web services. And then, we have the Xamarin.Mobile component which has Location, Camera, and Photo access. As an example, here, we have some code to take a picture using Xamarin.Mobile. This code works on iOS, Android, as well as Windows apps. The media picker that you see here provides access to the photo as a file or as a stream. So then, you can load it into whatever the platfo

From XAML to Xamarin

Recently I started exploring Xamarin Cross-platform framework ( Xamarin.Forms ) to develop apps for Android, iOS and UWP. There are couple of frameworks for doing cross-platform mobile app development, however,  as I am dominantly a C#/WPF developer, I chose Xamarin.Forms. This decision turned out to be the best decision, mainly because I had vast experience using Xaml and C# and saved 80% of my learning time. It was a great experience with Visual Studio integration of Xamarin and It took only 4-5 days to get acquainted with Xamarin. I will soon be uploading my app on Play stores, but first let me share the Pros and Cons I found: Advantages: Xamarin & .NET are very well architectures. C# is a fantastic language. Being able to use C# to develop on not just one, but 3 platforms. Since 2017, its completely Free. Xamarin allows to take my knowledge of C# and apply this to the iPhone and then Android. Can use existing c#/.net knowledge in iOS and Android. I

How UI Layout Works

Image
Few days ago, I was stuck with a GUI issue where WPF controls were not getting rendered in memory. Everything was arranged properly in a Visual Tree of parent control but still somehow child was not able to draw with custom size. So, to solve this issue I took  help of a book called WPF Control Development by Kevin Hoffman. I thought I should share how this layout process works under the hood. So there it is: ___________________________________________________________________________ The layout system in WPF is a conversation between the layout container and its children. This conversation takes place in two stages that are often referred to as passes. This two-pass approach starts at the root of the visual tree and recursively traverses the tree until all containers have been given the chance to perform the layout process with their children. In the first pass of the conversation, the parent asks its children how much space they need to display themselves. The parent infor

Increase Performance of your UI using Virtualization

Image
Recently I found an interesting article written by  Eric Stollnitz on increasing UI performance when Lists and collections are involved in your UI. Worth a read. Please follow this link:  UI Virtualization  

Single Textblock with multiple Font settings

Image
Today, I faced a requirement where I had to show some text and a down-arrow in default Ribbon control. Now, since this ribbon can have only one child, I had to come up with smart solution without much of code-behind. Application Menu After surfing, I got to know about this Inline feature of Textblock. TextBlock.Inlines property states:  An  InlineCollection  containing the  Inline  elements that comprise the contents of the  TextBlock . I added: You can also go with code-behind solution like this: