Visual Studio - James Montemagno https://staging.montemagno.com/tag/visual-studio/ https://staging.montemagno.com/content/images/2017/08/MonogramIcon_Orange_NoBuffer.png Visual Studio - James Montemagno https://staging.montemagno.com/tag/visual-studio/ Hugo -- gohugo.io Tue, 13 Oct 2026 20:48:55 GMT 60 Developing Android Apps on Windows Arm Devices https://staging.montemagno.com/developing-android-apps-on-windows-arm/ 644961ecfaa091003df357e4 Thu, 27 Apr 2023 23:00:11 GMT

I have gone all in on Arm devices! My main MAC machine is a Mac Book Air M1 and now my main driver at work is a Windows Dev Kit 2023 (aka Project Volterra). One tricky thing for developers is getting all the software we use to work properly on Arm. Things have come a long way since the original release of Arm devices for Mac and Windows. I have a full setup guide for my M1 for Xamarin and now .NET MAUI development, but what about Windows?

Visual Studio 2022 recently released a full native Arm version and they have been adding more workloads for developers to use. .NET MAUI was recently introduced, which got me excited but I right away ran into an issue, which was that there are no compatible Android emulators for Windows Arm and apparently no plans from Google :(. So, what are our options? Two come to mind.

Deploy to a device

Well, it may be obvious, but you can just plug in a device and use something like Vysor to mirror your device. I am always a fan of deploying and testing on devices as you have full access to everything including Google Play services. As a bonus you don't drag down any resources on your main machine. If you don't have a device, you are still in luck!

Windows Subsystem for Android

That's right! I have blogged and talked about it a bunch, but the Windows Subsystem for Android(WSA) is a great way to deploy and debug applications on any Windows 11 machine. It has expanded into more regions since its first release, which is awesome. If you haven't heard about WSA, it is a mode that you can enable that allows you to run Android applications directly on your Windows machine. There are limitations of course, the largest being no access to Google Play services, but for a lot of developers this will get you off the ground running. Checkout my full video:

If you are using Visual Studio 2022 there is a great extension that will help you get up and running and automatically connect.

Once you have it all set up, it is ready and available!

So, there you go! Two ways to get deploying Android apps if you are developing on a Windows Arm device.

]]>
Code Generation from XAML in Visual Studio is Mind-blowing Awesome https://staging.montemagno.com/code-generation-from-xaml-in-visual-studio/ 605f72ee20df30003b2b3b83 Sat, 27 Mar 2021 18:57:22 GMT

The more and IDE or code editor can do for you the better I say. Visual Studio has been crushing it with new refactorings, IntelliSense, and IntelliCode, one of my favorite features ever. One thing that I have always been hoping for as a XAML developer is deeper connectivity between the XAML and the View-Model. We have seen increased IntelliSense in this area, but with the release of Visual Studio 2019 v16.9 comes code generation from XAML! That is right, you can now have Visual Studio automatically create your properties, commands, and more!

I will walk through this awesome feature for Xamarin.Forms, WPF, and UWP, but if you just want to see it in action, I made an entire video:

Enabling Code Generation

The first thing to do is to create your ViewModel and implement INotifyPropertyChanged (or inherit from something that does). Then just create a control with a Binding associated with it. For example:

<StackLayout>
    <Label Text="{Binding Text}"/>
</StackLayout>

Once you do this, Visual Studio will put little dots under the Text binding and a lightbulb will show up (if you don't see this simply re-compile). The lightbulb will look to assign your x:DataType in Xamarin.Forms or d:DataContext in WPF/UWP.

Lightbulb in Visual studio to set x:DataType

When I selected this option, it auto added the following code:

xmlns:app1="clr-namespace:App1"
x:DataType="app1:MyViewModel"

What is x:DataType you may be asking? Well, it is a compiled binding, which makes your bindings and apps faster! This is an awesome feature of Xamarin.Forms that you should totally use!

With this code in place, you will now see the dots remain and a new lightbulb show up to create a property called Text for you!

Lightbulb and code preview to generate text

Here, it is recommending adding the property and creating a SetProperty method to invoke PropertyChanged, which is AWESOME!!!! Now, at this point you probably want to refactor the code a little bit and create  BaseViewModel that you put this method in and then in future ViewModels it will not attempt to create the code and just add the property. If you are using Mvvm Helpers, you can use this code as your base:

public class ViewModelBase : BaseViewModel
{
	public bool SetProperty<T>(ref T field, T newValue, [CallerMemberName] string propertyName = null) =>
		SetProperty<T>(ref field, newValue, propertyName, null, null);
}

Now, if you add another control with another binding, you will see nice tight code will be generated for you:

Another property being added with only a get/set

Is your mind blown yet?!?!? Mine is! However, it gets even better!

Generating Commands!

Now, let's say we are going to add a Command to a Button we would naturally want that code to be generated as well, correct? Well, you are in luck because it will!

Command and method being created!

This code is really neat because it not only created the command and the method, but it also brought in the correct namespace to use the Xamarin.Forms Command!

Command Generation on UWP/WPF

If you are over on UWP or WPF you will not see this code generation because the core framework does not have an implementation of ICommand. However, if you are using a framework or library such as Mvvm Helpers then it will be smart enough to figure it out and recommend code for you!

Code for a command being generated with Mvvm Helpers

MIND BLOWN!!!! ARE YOU NOT IMPRESSED!?!?!? Amazing!

Cleaner Code with C# 8 & 9!

One of the things you may have noticed is that the code for Xamarin.Forms and WPF/UWP are different in the screenshots. That is because my WPF sample app is using .NET 5, which uses C# 9 by default. The Xamrin.Forms app is using .NET Standard 2.0, which defaults to C# 7. However, you can easily adjust what version of C# is used in your project by adding the LangVersion into your csproj.

<LangVersion>8.0</LangVersion>

Take a look at my previous blog about upgraded a project to C# 9 in a minute.

Once you upgrade to 8.0 or higher the old code:

private ICommand clickCommand;

public ICommand ClickCommand
{
	get
	{
		if (clickCommand == null)
		{
			clickCommand = new Command(Click);
		}

		return clickCommand;
	}
}

private void Click()
{
}

will be upgraded to this lovely clean tight code:

private ICommand clickCommand;
public ICommand ClickCommand => clickCommand ??= new Command(Click);

private void Click()
{
}

Code Generation for Models

So far we have had Visual Studio generate code in our ViewModel classes on our page, but what about our models that are bound to an ItemsSource in a ListView or CollectionView Well no worries, all you need to do is set your x:DataType on your DataTemplate:

<ListView ItemsSource="{Binding Items}">
    <ListView.ItemTemplate>
        <DataTemplate x:DataType="app1:Item">
            <ViewCell>
                <Label Text="{Binding Text}"/>
            </ViewCell>
        </DataTemplate>
    </ListView.ItemTemplate>
</ListView>

Then you will see lightbulbs on any control inside of the DataTemplate!!

Code being generated inside of the data model

Again, this is pretty mind blowing and amazing! I was able to create all of my ViewModels and Models all without leaving the XAML!

Just the start!

This is all from me just playing around with Visual Studio 2019 v16.9 for a few minutes exploring this awesome new feature. There is for sure much more to come as Marco from the XAML Tooling team tweeted about the new feature and discussed with commentors about extending the templates for code that is being generated. Also, as of right now this is just a feature on Visual Studio on Windows, but since Visual Studio for Mac uses pretty much the same engine, we can imagine it will make its way to VSM soon.

This is just one of the many features that was included in Visual Studio 2019 v16.9 so check the release notes and upgrade today!

]]>
New Plugin for Xamarin & Multi-Target Templates for Visual Studio 2017 https://staging.montemagno.com/new-plugin-for-xamarin-multi-target-templates-for-visual-studio-2017/ 5a9591d2fb30940021201f7f Tue, 27 Feb 2018 18:04:12 GMT It is 2018 and I am all in on Multi-Target projects for building libraries and plugins. I love them so much that I convinced Frank to record a full episode of Merge Conflict on why this whole thing is so absolutely amazing.

I have slowly been converting all of my plugins over to mutli-targeted projects, which has reduced some of the solutions from 15 project down to 1!!!

image

There is a bit of tiny setup required for multi-targeting and for it to automatically pump out the NuGet package for you, which is why I updated my Plugin for Xamarin Templates for Visual Studio 2017! It handles everything for you automatically :)

Not only great for Plugins, but any cross-platform library!

Here is a full walkthrough of exactly how they work:

]]>
How to Convert a Portable Class Library to .NET Standard and Keep Git History https://staging.montemagno.com/how-to-convert-a-pcl-library-to-net-standard-and-keep-git-history/ 5a78e84dda32ce0022cbd5fe Tue, 13 Feb 2018 22:00:00 GMT I have had a lot of developers telling me that they have wanted to switch to .NET Standard Libraries, but that they are worried about losing git history. I have also heard fears of compatibility with existing packages. Do not fear! It is so simple to switch over to .NET Standard and takes minutes!

Why .NET Standard 2.0

There is simply no reason not to be using .NET Standard 2.0 at this point (you can still target 1.4 if you need older UWP support, but just do 2.0!). It supports all of your favorite platforms including every single Xamarin platform, offers 20K+ more APIs than 1.X, and has a 70% API compatibility with NuGet packages today (it will also consume non-.NET Standard libraries in a compat mode). On top of that it is the future! It replaces PCL and Shared Projects (with multi-targeting, which I will save for another blog post) and will make your life as a cross-platform developer much more enjoyable.

Easy as 1,2,3,4 🐒

  1. Unload your PCL project (right click -> unload), and start editing it (right -> click edit)
  2. Delete Everything in the csproj and insert this:
<Project Sdk="Microsoft.NET.Sdk">
  <PropertyGroup>
    <TargetFramework>netstandard2.0</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <!--<PackageReference Include="" Version=""/>-->
  </ItemGroup>

</Project>
  1. Add back NuGets (simply open packages.config, and add the package references above, or via the NuGet package manager.
  2. Delete AssemblyInfo.cs (this is now in the csproj) and packages.config (also in csproj via PackageReference)

That is it! You are done! Welcome to the wonderful world of .NET Standard 2.0! If you had any reference to other projects you will want to add those back in!

So Easy Let Me Show You

That is right, it is so easy that I shot an entire 6 minute video where I do this in real time!

Learn More

To learn more about .NET Standard head over to the documentation and to follow along with my Git commits you can find the source code to the library I converted in the video over on my GitHub.

Additionally, Frank and I discussed .NET Standard on Merge Conflict:

]]>
Paste JSON as Code with quicktype.io in Visual Studio https://staging.montemagno.com/paste-json-as-code-with-quicktype-io-in-visual-studio/ 5a78ad62da32ce0022cbd5f6 Mon, 05 Feb 2018 21:00:00 GMT

quicktype! Yes that quicktype that I blogged about late last year on how to convert JSON to C# classes in the browser. I am back talking about it again because they have made tons of great enhancements and just today released a new extension for Visual Studio 2017! I should mention here that all of this is FREE.

PasteAsCode

Watch Now, Questions Later

Want to see it in action? Checkout my short video overview:

Doesn't VS Do This?

It is true that Visual Studio has a Paste JSON as Classes feature, but it basically does the bare minimum. quicktype will automatically add in JsonProperty names, has enhanced partial classes, better names on parameters, fills in a full class and namespace, and even adds helper classes for you so you don't have to write boiler plate code.

Here is a good example of the power of quicktype. Let's take the Azure Cognitive Services Text Analytics JSON that is returned from the RESTful call.

It is pretty complex JSON with mutliple classes and arrays. If I use the "Special Paste" we do get C# classes back, but they aren't very pretty.

I now have to go through and fix all of the parameter and class names and add in JsonProperty attributes to the tops.

Now let's see the quicktype version:

Now we are talking! Look at those pretty classes and parameters!

Alright, that is enough show an tell for today. Go grab the extension and tell them Motz sent you on their community Slack!

This is NOT sponsored content. I do know the awesome quicktype team and was given early access to the extension. I just believe this is an awesome tool developers should have

]]>
Xamarin Live Player - VS 2017 version 15.4 & 15.5 Awesomeness https://staging.montemagno.com/xamarin-live-player-vs-2017-version-15-5-awesomeness/ 59e6960ed67162002ee82e38 Wed, 18 Oct 2017 16:41:30 GMT Last week Visual Studio 2017 version 15.4 and VS for Mac 7.2 were released into the stable channel. They include the very first release of the Xamarin Live Player capabilities in Visual Studios. This means you can simply update Visual Studio, turn on Xamarin Live Player (Preview), and get started visualizing your mobile apps with nothing more than VS and your iOS or Android device!

image8

Whenever there is a stable release a new preview release of Visual Studio is not far behind. That is right, VS 2017 version 15.5 preview is available right now! It runs side-by-side your existing VS 2017 install and has tons of awesome new features that Pierce blogged about last week. I wanted to take a quick minute to point out some of this new awesome.

Right Click Live Run!

Finally, it happened! You can now right click on any XAML or C# file and live run it! Additionally, you can use the keyboard shortcut: Shift+ALT+F5.

RightClick

Live Run Entire App

A new feature in 15.5 enables the Live Run mode to instantly swap between any XAML or C# file that you have open. No need to ever stop and start the Live Run mode, simply change the focused file:

Live-Player-Swap-2

Live Run Banner

To help better find the Live Run feature there is now a small banner when opening a Xamarin.Forms XAML page. Simply click on Live Run to instantly see it on your device:

image11

Better Feedback

A lot of work has gone into giving proper feedback when things are deploying or errors that may occure with the Live Player.

Errors!

If your code has errors then it will not be deployed, but will instead show up in the Error console as you would expect. How cool, it wasn't actually even compiled... because nothing is compiled, yet the errors are shown.

image16

Deploy Information

In 15.4 the Live Player will output it's deploy information to the output window as to what files were being synchronized. Now in 15.5 the state of connection, transfer, and running are shown in the Visual Studio status bar:

LivePlayerStatus

So Much More

There are tons of nice little teaks and opitmizations to the Xamarin Live Player that I know you are going to love. Go download the latest version of Visual Studio and be sure to get the "Fast Ring" version of the app for the latest and greatest in app features.

In Action

Writing about new featuers is fun, but actually seeing them in action is better. So, I made a short video highlighting how to get started in Visual Studio 2017 version 15.4 and some of the new features in 15.5:

]]>
My Favorite C# 7 Feature: More expression-bodied members PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name)); This is amazing! However, in C# 7 things get even better. Take our good old friend property …]]> https://staging.montemagno.com/my-favorite-c-7-feature-more-expression-bodied/ 598df8f2c121b60019bf2fc7 Fri, 09 Jun 2017 19:33:37 GMT I can’t help myself, I love Expression-Bodied Members from C# 6! Combined with other powerful C# features it took this code:

public void OnPropertyChanged(string name)
{
  var changed = PropertyChanged;
  if(changed == null)
    return;

  changed(this, new PropertyChangedEventArgs(name));
}

to this:

public void OnPropertyChanged(string name)=>
  PropertyChanged?.Invoke(this, new PropertyChangedEventArgs(name));

This is amazing! However, in C# 7 things get even better. Take our good old friend property setters and getters:

public string Subtitle
{
  get { return subtitle; }
  set { SetProperty(ref subtitle, value); }
}

Look at all of those { and }, well no more! Here is some C# 7 for you:

public string Subtitle
{
    get => subtitle;
    set => SetProperty(ref subtitle, value);
}

You can even use our lambda friend on constructors and finalizers!!

// Expression-bodied constructor
public ExpressionMembersExample(string label) => this.Label = label;

// Expression-bodied finalizer
~ExpressionMembersExample() => Console.Error.WriteLine("Finalized!");

Mind Blown!! It is the small things that make me so happy. There are tons more great C# 7 features that you can now access in VS 2017 and VS for Mac and Frank and I discuss all of them on our podcast Merge Conflict that I hope you subscribe to!

Merge Conflict 47: You Got Some F# in My C#

]]>
Setting up Visual Studio 2017 for Xamarin Development https://staging.montemagno.com/setting-up-vs-2017-for-xamarin-dev/ 598df8f2c121b60019bf2fd1 Wed, 08 Mar 2017 17:31:33 GMT

Visual Studio 2017 was just released yesterday, and it is awesome! You can re-live all the keynote and demo deep dives on Channel 9. There are tons of new features and a huge revamp to installation but things to me still aren’t absolutely perfect in the setup of how I like to develop. So in the spirit of my Cycle 8 and Cycle 9 installation guides I am proud to bring you the ultimate VS 2017 Setup Guide for Xamarin!

Installation

The installation is brand new and pretty awesome. You now pick “workloads” of development that you want to install and it will take care of the rest. It is highly configurable, but the default for me of installing tons of stuff was super fast and installed in under 30 minutes! If you just do the core VS 2017 install it will be installed in under 5 minutes! That is crazy. For Xamarin development there is literally a Xamarin checkbox under mobile, it is the first choice and really the only choice you need:

Some other work loads I recommend are pointed out including:

  • UWP

  • .NET Development

  • ASP.NET

  • Azure

  • Data

  • and hidden at the bottom .NET Core

Additional Configuration for iOS

Since the Xamarin documentation is amazing on this go read it here.

Additional Configuration for Android

There are a few tweaks here that I must make to be happy for Android development. While the installer is nearly perfect, here is my recommendation.

1.) Install the latest JDK 1.8 x64 (currently 8u121)

Installing the x64 version on Windows is extremely important because it is needed for custom controls in the Android designer and also for the Xamarin.Forms Previewer to work. If you don’t have a x64 machine know that these are a few of the restrictions that may not work on your machine.

You will then need to set the path in the tools-options menu:

2.) Update Android SDKs & Emulators

This is just good to know in general because you will need to update things every once in a while, but from Tools -> Android, you are able to get to the Android SDK and Emulators, let’s start with SDK Manager.

The installer sets us up for success with SDK 23 and the build tools needed, but I like to install the latest and greatest for API 24 and optionally you can pick SDK Platform 25:

The first 3 are really important and you will want to grab those to compile with the latest and greatest.

Android Emulators

This actually gets its own section because it is a bit complicated. We now install the default Google Emulators, both Arm and x86. The latter, x86 are extremely fast, but require you to turn off Hyper-V and ensure that you have the Intel Hardware Accelerated Execution Manager (Intel HAXM) installed. So first, go turn off Hyper-V and then install Haxm and you will be nice and happy.

I then recommend going to the Android Emulator Manager and creating a new emulator with my preferred options:

I hear you yelling right now, JAMES I NEED MY HYPER-V!!!!!! Alright fine, then don’t install HAXM and install the Hyper-V VS Emulators for Android! Now there are some things to know with these. First, they are pretty nice and fast emulators. Second, you aren’t going to get the latest and greatest as they haven’t been updated in a while. Third, if you are running a Skylake or newer processor you need to turn on compatibility mode or your app will fail to debug. Lastly, there are no google play services or maps on them unless you hack around it and install gapps with this awesome guide.

Creating your first app!

It is time! Let’s create a new app with File -> new project, which will reveal all the Xamarin templates for mobile development:

If you are creating a solo iOS/Android/tvOS app with high fidelity UIs for each platform then head to those sections, if you want a cross platform solution or a Xamarin.Forms solution and project then head to Cross-Platform to discover the new Cross Platform App Template.

This will bring up a wizard to guide you through creating your first Blank app for Xamarin Native or Xamarin.Forms! 

There you have it! You should be all setup for success and building mobile apps in no time. Be sure to checkout the Xamarin blog on all the new stuff in VS 2017.

]]>
New Xamarin.Forms Item Templates!! https://staging.montemagno.com/new-xamarin-forms-item-templates/ 598df8f2c121b60019bf2fd7 Wed, 25 Jan 2017 23:26:06 GMT I just installed the latest RC for Cycle 9 and was extremely surprised and happy to find some brand new Item Templates for Xamarin.Forms including:

  • Carousel Page

  • List View Page

  • Map Page

  • Tabbed Page

Along with the awesome new project template creation!

When you add a page it will scaffold out your entire ViewModel too!!! Amazing! Just by adding the ListView Page you get this:

New Tabbed Page:

I did a little Motz Codes Live walkthrough, check it out:

]]>
Visual Studio - Unable to launch Google Android Emulators https://staging.montemagno.com/visual-studio-unable-to-launch-google-android/ 598df8f2c121b60019bf2fe3 Fri, 18 Nov 2016 21:59:23 GMT When developing with Xamarin in Visual Studio you have a lot of options for Android Emulators. You can go with the VS Emulators for Android powered by Hyper-V, Genymotion, or the out of the box x86 HAXM powered Android Emulators from Google (a few are installed for you already). It looks though that with some of the latest updates to Windows and VS when you go to launch them you get an error message that they can’t be launched. If you look at the logs you will see something like this:

Error message:
qemu-system-i386.exe: -drive if=none,index=0,id=system,file=C:\PROGRA~2\Android\ANDROI~1/system-images\android-23\google_apis\x86\/system.img: could not open disk image C:\PROGRA~2\Android\ANDROI~1/system-images\android-23\google_apis\x86\/system.img: Could not open ‘C:\PROGRA~2\Android\ANDROI~1/system-images\android-23\google_apis\x86\/system.img’: Permission denied

This is because of where VS installs the Android SDK, which is sad :(

Simple fix…

Run AVD Manager or Visual Studio as Administrator:

Now it will start up again!

]]>
Getting Started With & Learning C# https://staging.montemagno.com/getting-started-with-csharp/ 598df8f2c121b60019bf2fe4 Tue, 15 Nov 2016 17:32:43 GMT In 2006, after years of writing C++ and Java code, while attending UAT an instructor named Phil Miller introduced me to this amazing language called C# and changed my life. It was love at first “Hello World” and I have never looked back. C# is an extremely powerful, mature, and extremely cross-platform programming language that I have been using for decades. The beauty of C# of course is that you get this amazing cross-platform framework called .NET, which gives developers ability to perform RESTful service calls, perform math operations, and just about anything else you can possibly think of. With all my C# love I often forget how I learned it all and when I attempt to walk through the basics with new developers I struggle a bit. After talking with a bunch of developers over the last few months I have a 4 step plan when you want to learn C#. I am often extremely interested in how you learned C# and your recommendations, so leave them in the comments.

Learn & Write Some Code in the Browser

That is right! You would think that you would need a full IDE to even start learning and writing C#, but you would be wrong. There is a lovely and amazing website that Microsoft recently published called www.dot.net. Inside of that website is an overview of what .NET is and the languages you can use, but also an amazing learn section, where you can learn about C#, structures, functions, and TONS more…. ALL IN THE BROWSER! There is an interactive IDE/REPL thingy that will take your code and compile it in the cloud (The Azure Cloud).

Here is the direct link: https://www.microsoft.com/net/tutorials/csharp/getting-started

Grab an IDE

You have to write some code somewhere at some point and you have a lot of great options here.

Visual Studio Code

By far this is the most light weight, cross-platform, and easy to install IDE out there. Simply head to code.visualstudio.com and select Code. It works on PC, macOS, and even Linux. When you want to start writing some C# code you will also need the C# extension… the #1 extension. Simply tap on the extension section on the left and search for C#. Done!

Visual Studio Community Edition for PC

We are now in the full IDE world with Visual Studio, the best IDE ever created, and it is completely free! Community Edition is fully featured and allows you to make apps for a plethora of different platforms including mobile platforms such as iOS and Android in C# with Xamarin!

VS is a bigger install so give it some time, but you can select a console app, WPF, UWP, or Xamarin app and you are off to the races. Get it from http://www.visualstudio.com

Visual Studio for Mac

If you are over on a macOS device do not fear as Visual Studio for Machas you covered. While not as verbose as Visual Studio for PC, Visual Studio for Mac focuses on mobile iOS, Android, and macOS apps written in C# with Xamarin in addition to .NET Core, ASP.NET Core, Azure Functions, and even Unity development. This is also completely FREE and easy to install by heading to visualstudio.com.

On the Go with Continuous for iPad

My good friend Frank Krueger is an absolute genius and created his own fully featured C# IDE for the iPad called Continuous. It is the only paid IDE coming in at $9.99, but it is amazing and you can even write full iOS apps in C# with Xamarin with it.

Check out more at http://continuous.codes

Take Bob Tabor’s MVA Class

One of the biggest recommendations that I have heard is the now extremely famous and completely free C# class by Bob Tabor. This free class on Microsoft Virtual Academy has literally changed my friends careers by teaching them C#. Bob is extremely well known and has great classes on a bunch of awesome languages, but his C# is top rated, so check them out right now on Microsoft Virtual Academy.

Pick a Platform & Go

Once you have C# basics down it is time to go pick a platform to start tackling. Write a simple application for web, mobile, or desktop that does one or two things on a single page. With the C# basics down you are able to go off and learn some platform specifics. Here is a good place to start:

Have Fun

C# is my favorite programming language in the entire world and I hope that it soon becomes your favorite too.

]]>
Visual Studio Code, your new Markdown editor https://staging.montemagno.com/visual-studio-code-your-new-markdown-editor/ 598df8f2c121b60019bf2fec Wed, 13 Jul 2016 17:44:10 GMT I feel like I have been spoiled for a long time using macOS as there have been a plethora of great Markdown editors. Now that I am full time on a Surface Book and Windows 10 it saddened me that a version of Mou wasn’t coming or planned at all. I write Markdown just about every day between the libraries on my GitHub and writing blogs and documentation. I have always used VS Code for just light weight text editing and now that it not only runs everywhere, but also supports all sorts of extensions I thought there had to be some form of markdown extension to get me through the day.

 When you boot up VS Code, it isn’t straight forward as to how to get to extensions.You will need to go to View -> Extensions

This brings up the Extensions manager and if you type in @popular then you will see the top extensions. (#1 being C#, which is awesome).

Simply searching for “markdown” gets you into a world of trouble as there are tons of hits all with no icons or real reviews or downloads. Do not worry because I have done all the hard work for you and test a bunch of them out and the one we want to install is “Auto-Open Markdown Preview” (currently version 0.0.3), because it is AMAZING.

Now, you will probably have to re-start and then just open up a markdown file:

Glorious! With images and everything. It is awesome! Enjoy!

]]>
New & Improved Xamarin.Android Templates for Visual Studio https://staging.montemagno.com/new-improved-xamarinandroid-templates-for/ 598df8f2c121b60019bf3005 Fri, 10 Jul 2015 00:38:21 GMT

It has been a bit over a year since I first introduced my Xamarin.Android Templates pack for Visual Studio and things sure have changed in the world of Android since then. Early on the templates pack only introduced a few item templates for menu items and a simple implementation of the Navigation Drawer, my favorite way to navigate in Android. Then this March Google went and changed everything with AppCompat and the introduction of the new Toolbar. I rushed to update all of my templates to include all these nice new features. It looks like it is that time of the year again with the new Android Design Support Library, which yet again changes how we implement the Navigation Drawer and of course let’s not forget about the big change to AppCompatActivity. 

I am pleased to announce the latest release of my templates that incorporate all of these changes to make it easy to get up and running with AppCompat and the new fancy navigation drawer featuring the NavigationView.

You can grab these templates from the Visual Studio Gallery by going to “Tools->Extensions and Updates” in any flavor of Visual Studio and searching for Xamarin.Android Templates. 

Once installed you will see a few new Project Templates under Android to create a blank app that features AppCompat or a full Navigation Drawer enabled app also featuring AppCompat:

Once you have your app up and running you might want to add a few new menu items such as search, share, or just a menu item and I have you covered:

Of course everything is open source on GitHub so you take take a peek at what I am doing in the templates. Additionally, if you already have an app and are looking to upgrade your navigation drawer or tabs to the new material support library implementations then look no further than my Xam.NavDrawer GitHub repo that has been updated with an awesome new example! 

I hope you enjoy these new updated templates and I look forward to your feedback or suggestions for future updates!

]]>
Adding Shared Projects Support For Xamarin In Visual Studio 2013 https://staging.montemagno.com/adding-shared-projects-support-for-xamarin-in/ 598df8f2c121b60019bf3021 Wed, 12 Nov 2014 00:19:10 GMT While I love portable class libraries for sharing code across multiple projects, and I absolutely love Shared Projects for sharing code within a single library or project. Shared Projects were introduced with Visual Studio 2013 Update 2 and quickly added to Xamarin Studio enabling you share code easier than ever. The two ways of sharing code are vastly different and you can read about them on the amazing Xamarin documentation, but what you really need to know is that a PCL is an assembly with references and a Shared Project is glorified file linking but contains everything under a project node making it easy to navigate and never having to link a file again. This means that these files are just that….files of code that enable you to do conditional compilation and all that jazz :)

The Problem

The real issue is that when VS 2013 Update 2 shipped it only added Shared Projects if you were creating a Universal App and there was no way to create a separate Shared Project or even easily add one to a non-Universal App. There is no reason for this though as you can “easily” modify the .csproj files to get it working.

The Solution

Since manually editing a .csproj is no fun the good people at Microsoft created a Visual Studio extension called the “Shared Project Reference Manager Extension”, which you can find on the Visual Studio Gallery. You can get to this from “Tools -> Extensions & Updates -> Online” and search for Shared Projects:

Once you have this installed you can simply do a File->New Project and under C# you will see a shared project!

With your shared project in place simply right click on your “References” of your Xamarin iOS or Android app and you will see a new “Add Shared Reference…” entry in the context menu. After that you are all set and ready to share code. Of course there is nothing special you need to do in Xamarin Studio as it just works out of the box :)

I even have a full video breakdown that you can watch as well:

]]>
Shared Code Projects in VS: Windows Phone, Windows Store, and Xamarin! https://staging.montemagno.com/shared-code-projects-in-vs-windows-phone-windows/ 598df8f2c121b60019bf3033 Fri, 18 Apr 2014 23:36:00 GMT At Build, Microsoft announced Shared Code Projects to simplify how developers are sharing code between platforms. We have had official portable class library support for Xamarin apps since late last year and it has been wonderful, however once you mix WP8 into the mix the PCL profiles get a bit limited. Shared Code Projects attempt to fix this by allowing you to create a project that are a shell for code that can be added into any project. It is basically glorified file linking with a nice UI to help you debug your code better per project. You will still have to do a bunch of #ifdefs though if you are trying to use functionality that is not available in a specific platform.

Shared Code != Universal App && Shared Code != PCL

So it should be stated that Shared Code projects are not universal apps and they are not PCLs. A Universal App is just a project template for WP8.1 and WinStore 8.1 apps that use a shared code project. The idea of a Universal App is simply that these two platforms have a shared project and maybe they are able to share some of the UI which is XAML (I still have to explore this more). Also, a Shared Code project differs from a PCL because the PCL does not have the ability to call platform specific code without an abstraction layer like the shared code project can. Additionally, they work completely different at Compile vs Deploy time. Remember that PCL’s can compile against a “contract” and implementation, but at build and deploy time the platform specific version will is used. The shared code project is compiling and deploying against what is in each parent project and their references.

So to me this means that a PCL is for library creators and a Shared Code project is for app creators, but an app creator can also live completely in PCL land if they want. I have been and I enjoy it, but I am still constrained to what PCL limits me to, but allows me to easily add platforms in the future without modifying code. So I think I will start more projects with shared code projects in the future.

Get it in VS!

While Miguel tweeted that support for shared code projects will be added to XS in the future if you live 100% of the time in VS then you can get started today with shared code projects. The first thing you need to do is install the shared code project visual studio plugin assuming you already have Visual Studio 2013 Update 2 RC installed.

With that installed we can go ahead and create a new project:

Then you can add in your iOS and Android apps like normal. Once you want to start writing code in your Shared Code Project you will want to add them as a reference to your other projects so you can get intellisense and bring in namespaces.

Once I have added them here you will be able to see the reference in the project references:

What am I coding against?

Shared code project actually have no references… well actually they have every reference of the parent. What is really cool is that you can toggle between each project when you have a file open from the shared code project.

This means you will probably have to do a lot of toggling between everything to make sure it compiles correctly, but it is pretty slick. So now if I wanted to add HttpClient into the mix here I would add the reference to my iOS and Android project like I normally would, and then start writing code in my Shared Code project:

And there you have it, Shared Code projects integrated into Visual Studio for Xamarin projects!

]]>