Simple example for MongoDB. Save and retrieve data from Azure Cosmos DB. Create an Azure Cosmos Db as MongoDb For creating a new MongoDb on Azure, search from the list of resources, Azure Cosmos Db. Then Add a new database and you see the following screen. Overview When you created a new MongoDb, you see an Overview where there are general information about how many queries the database did (split on insert, update, cancel, query, count, others). Under Connection String you have the connection to use in your application. In…
Never give up!
Surface phone: is it the real time?
Surface Phone Rumors: Microsoft to Finally Unveil Mythical Device at the MWC 2018. While some people are resigned to the fact that the long-rumored Surface Phone is nothing more than a figment of the imagination, new reports claim that the long-rumored mythical Microsoft device may finally be unveiled at next month’s MWC (Mobile World Congress). Rumors about the Surface Phone have been in existence for two years now, but no one outside Microsoft cannot really confirm if the device is in the pipeline. However, according to recent reports, the wait…
First AngularJs example
If you are looking around for a new job as .NET developer, all companies are asking you AngularJs. Then I’m starting to learn it and I share with you the secret of this framework. I’m assuming you are a .NET developer like me and you want to learn AngularJs and then I won’t explain you the basis of HTML. Open Visual Studio and create a new solution with ASP.NET Empty web Site. Now you have your project. Add from NuGet AngularJS.Core. Done. We start now with a little complicate example.…
Add a macOS project to your existing solution
With the new version of Xamarin, we can create apps for macOS. But how can I add a macOS project to my solution? I explain step by step what we have to do. Add new project The first step is to add a new project for macOS in your solution. Right-click on your solution and select Add New project… Now select from the list App under Mac and then Cocoa App. Then name your project, usually, we call this project with yourprojectname.macOS.
Get the Most Out of iOS 11 with Visual Studio Tools for Xamarin
Join Craig Dunn explains what’s new in iOS 11 and how to take advantage of the latest updates – from drag-and-drop for iPad to machine learning and more – 100% in .NET and Visual Studio. Whether you’re building new or updating existing Xamarin.iOS apps, you’ll see how to implement new frameworks, APIs, and UI features, walk-through code samples, get expert tips and tricks, so you can start shipping iOS 11-ready apps to your users. In this webinar, you’ll: Explore iOS 11 UI changes, including adapting to the iPhone X form…
What Singleton Pattern is in C# and its implementation
In another post I discussed how to implement Inversion of Control Pattern in C#. In this post I should explain what a singleton is. The singleton pattern is one of the best-known patterns in software engineering. Essentially, a singleton is a class which only allows a single instance of itself to be created and usually gives simple access to that instance. Most commonly, singletons don’t allow any parameters to be specified when creating the instance – as otherwise, a second request for an instance but with a different parameter could…
How To Append ‘st’, ‘nd’, ‘rd’ or ‘th’ To Day Numbers in Dates
For a new project, my client required to output date strings in a format that included the two letter suffix added to the day number, like in British date (“January 1st 2018” as opposed to “January 1 2018”). The solution makes use of the custom formatting capabilities in the framework whereby it is possible to implement the IFormatProvider and ICustomFormatter interfaces to provide custom string formatting for use with methods that support formatting such as String.Format() or Console.WriteLine(). I decided to extend the existing DateTime format provision in the framework…
Xamarin Forms: TranslateY (or other properties) for platform
Sometimes you need to change a value for a specific platform and this value is a Double, for example. I spent a couple of minutes to find a working code. <Label> <Label.TranslationY> <OnPlatform x:TypeArguments=”x:Double” Android=”-10″ /> </Label.TranslationY> </Label> Happy coding!
The Invoke Smart Speaker Brings Microsoft’s Cortana AI to Your Living Room
Cortana virtual assistant already integrates into Windows 10, works on iOS and Android, and will start showing up in cars soon, it’s ready for your home with Invoke. It’s good for work, good for play, even has a cool name. The new Invoke speaker, made by Harman Kardon, is more or less a direct copy of the Amazon Echo – a tall, cylindrical speaker with a blue light at the top that glows when the speaker is listening to you. It can control some of your smart-home devices, set reminders,…
Enable and control iOS 11 Large Titles in Xamarin.Forms
Apple introduced with iOS 11 a new UI in particular for larger titles: if you open your email, you see at the top a large title. That sit in the Navigation Bar and can be scrolled away when more space is needed. We can enable large titles with a renderer. For this example, I only created a new project and added the following renderer in the iOS project under Renderers folder. You can easily add to all your solution the following renderer in your iOS project: using System; using YourProject.iOS.Renderers;…
UriBuilder in Xamarin Forms
In Xamarin Forms there is a native function called UriBuilder: it allow you to create a well-formed url. In my implementation, all parameters are in a Dictionary called parameters. Using Linq, I put in builder.Query only the parameters with a value. UriBuilder builder = new UriBuilder(yourUrl); Dictionary<string, string> parameters = new Dictionary<string, string>(); parameters.Add(“reference”, Reference); parameters.Add(“param1”, Param1); builder.Query = string.Join(“&”, parameters.Where(p => !string.IsNullOrWhiteSpace(p.Value)) .Select(p => string.Format(“{0}={1}”, Uri.EscapeDataString(p.Key), Uri.EscapeDataString(p.Value)))); return builder.ToString(); Happy coding!
Microsoft release new XAML Controls Gallery app to help developers implement Fluent Design
Microsoft is hoping developers will be updating their UWP apps en masse to support their new Fluent Design language, and to help them along Microsoft has published an app in the store that demonstrates all the controls available. “XAML Controls Gallery” demonstrates all of the controls available in Fluent Design System and XAML. It’s the interactive companion to the Fluent Design System web site which can be seen here. According to Microsoft, the new Microsoft Fluent Design System will deliver “intuitive, harmonious, responsive and inclusive cross-device experiences and interactions” for…
Binding FormattedString for Xamarin Forms
Xamarin Forms doesn’t have a Label with a Bindable FormattedString. For example, if you want a bindable bold word in the middle of a sentence in a Label, it’s very hard to design it with common control. For that, I create my own component for that. LabelRenderer.cs using System.Collections.Generic; using System.Collections.ObjectModel; using System.Collections.Specialized; using System.Linq; using System.Runtime.CompilerServices; using Xamarin.Forms; namespace PSC.Controls { public class Label : Xamarin.Forms.Label { protected override void OnBindingContextChanged() { base.OnBindingContextChanged(); UpdateFormattedTextBindingContext(); } protected override void OnPropertyChanged( [CallerMemberName] string propertyName = null) { base.OnPropertyChanged(propertyName); if (propertyName ==…
Microsoft Launcher review: A beautiful Android experience
After Microsoft gives up on Windows 10 Mobile, Microsoft Launcher is the upgraded version of the Microsoft Garage project Arrow Launcher, and we covered the key changes that came with that upgrade last week. It’s free and can be picked up from the Google Play Store. After some heavy usage over the last few days, we’re breaking down what works, what doesn’t, and where Microsoft should take their launcher from here. As Microsoft Launcher gains more publicity, there have been some rumblings about how it doesn’t look like Windows 10…
Microsoft gives up on Windows 10 Mobile
The company’s Windows 10 chief has tweeted that developing new features and hardware for the Mobile version of the OS was no longer a "focus". Joe Belfiore added that he had also switched to Android himself. Windows 10 Mobile tried to attract users by letting them run the same "universal apps" on both their PCs and handsets, but the concept failed to catch on. The OS accounted for just 0.03% of the global market – based on smartphone shipments – between April and June, according to research company IDC. The…
Xamarin Forms Repeater View
A ListView is a kind of repeater but isn’t always what I want. It’s surprising something like this isn’t included in the framework but making your own is fairly simple. namespace PSC.Controls { /// <summary> /// Repeater view. /// </summary> public class RepeaterView : StackLayout { /// <summary> /// The item template property. /// </summary> public static readonly BindableProperty ItemTemplateProperty = BindableProperty.Create( “ItemTemplate”, typeof(DataTemplate), typeof(RepeaterView), null, propertyChanged: (bindable, value, newValue) => Populate(bindable)); /// <summary> /// The items source property. /// </summary> public static readonly BindableProperty ItemsSourceProperty = BindableProperty.Create( “ItemsSource”, typeof(IEnumerable),…
Hey Cortana, open Alexa: Microsoft and Amazon’s first-of-its-kind collaboration
I talk to Cortana every day — at home, work and on-the-go — to get information about my day, to set reminders so I don’t forget things, and to answer my questions. But I don’t just use one digital assistant. I also frequently talk to Alexa to listen to audio books or to add things to my shopping list. Because people use and interact with all kinds of products, we’re very excited to announce a first-of-its-kind collaboration with Amazon between Cortana and Alexa that will offer more choice, value and…
Xamarin, no show images in the device but only in the simulator
In my project I have some images to display. The funny thing is I can see images in the simulator but not in a real device. Simulator iPhone (real device) Solution iPhone is case-sensitive and the name of your images must be specified correctly. iOS Simulator probably is not case-sensitive and then it displays images with every name.
Xamarin, Android and starting a service at device boot
In my previous post called Xamarin: how to Start an Application at Device Boot in Android, I explained how you can change your Android Xamarin’s project to launch your app at the device boot. It is a good start but my problem was a bit more complex. I want to create a background service to track the geolocation of a device. I googled a lot to find a solution without a great success. Then I started to implement my code with some tests. Finally, I found a good way and…
Xamarin: how to Start an Application at Device Bootup in Android
This tutorial will explain to stat an application while the Android device boot-up. For this, we need to listen to the BOOT_COMPLETED action and react to it. BOOT_COMPLETED is a Broadcast Action that is broadcast once, after the system has finished booting. You can listen to this action by creating a BroadcastReceiver that then starts your launch Activity when it receives an intent with the BOOT_COMPLETED action. Add this permission to your manifest In your Android.Manifest you must add thi permission: <uses-permission android:name=”android.permission.RECEIVE_BOOT_COMPLETED” /> Then open this file and…
Eat Cookies!
What are Cookies? Cookies are data, stored in small text files, on your computer. When a web server has sent a web page to a browser, the connection is shut down, and the server forgets everything about the user. Cookies were invented to solve the problem "how to remember information about the user": When a user visits a web page, his name can be stored in a cookie. Next time the user visits the page, the cookie "remembers" his name. Cookies are saved in name-value pairs like: username = John…
C# and multicultural IsDate() and ToDate()
C# does not provide IsDate() function. Sometimes in your developer environment region settings are different from the live environment. In my case, I don’t know what region settings there are in my company servers. For this reason, I created a function to check is a string is a date in a culture and to convert a string to a date. /// /// Determines whether the specified text is date. /// /// The text. /// /// true if the specified text is date; /// otherwise, false. /// public static bool IsDate(this…
Device name in Xamarin
Using Device Information Plugin for Xamarin and Windows, you have access to same information for a device: GenerateAppId: used to generate a unique Id for your app. Id: this is the device specific Id Device Model: get the model of the device Version: get the version of the Operating System If you want the device name, it’s not in this list. Then for that we can create our functions. IDevice interface First of all we have to create an interface, I call it IDevice. using System; namespace myApp.Interfaces { public…
Microsoft says iOS and Android support doesn’t mean Windows Phone is dead
In an interview with Business Insider, Microsoft’s Joe Belfiore spoke briefly about Microsoft’s recent announcements made at Build such as the Windows 10 Fall Creators Update but also took the time to comfort those worried about the small presence of Windows phones at the event and Microsoft’s growing focus on iOS and Android devices. “We’re going to continue to support Windows phone,” Belfiore said before adding that, “Windows is a platform that drives the experience on a whole range of devices. We live in a highly diverse world.” With the…