Office 2013 – How to get rid of extra space between commands

If you got a non-touch laptop and you use office 2013 and notice extra space between commands on ribbon in office 2013, reason for this is that your office 2013 is in touch optimized mode, follow steps below to switch to optimized for mouse mode which will get rid of the extra spaces between commands.

From the quick access toolbar select “touch/mouse mode” this will bring up an addition item onto the toolbar, see screenshot below


Clicking this option will bring up a drop menu which allows you to switch between mouse and touch, switch to mouse and you will find extra spaces between commands on ribbon disappearing. This change is global and affects across the entire office suite, meaning if you change in word, you’ll see it on outlook, excel etc.

Hope this helps someone, thanks to my colleague for this tip



An Introductory post (

This is an introductory post to announce my new site, while I’m certainly not new to blogging, one of the things I realized is that since I started blogging initially on MSDN,  I’ve moved my blog from MSDN to other hosting providers and then coming back to MSDN while not maintaining consistent URL and preserving links to many of my older posts, I realize how frustrating this has been to readers of my blog. Granted not sure if many people read stuff I write :) but still…

I wanted to write this post and set the record straight “I screwed up”, I can assure you this site is here to stay, I’m currently hosting this blog on Azure websites using WordPress. I hope I wont have to move to another provider, even if I do I will take every step to ensure consistency on URL and preserve links to posts so you’ll never see broken links to my posts. Through this site I’m hoping to share information about developing for cloud and devices and hope you will find the site useful. I hope you will stay in touch with me through various options listed in contact page of this site and provide me any feedback you might have on the content here or things I can improve.



Targeting windows 8 platform when developing windows store apps using VS2013 + Win 8.1

Like most of the developers who always like to run on latest and greatest Microsoft software, I too upgraded my machine to Windows 8.1 and VS 2013, Today I was bit disappointed to find out that I could not develop windows store app and target windows 8 platform. When creating new projects in VS2013 using the windows store project templates, 8.1 is picked as a default for me, there is simply no way to change this to 8.0 through the VS UI, I tried editing the csproj file and changing the target platform version from 8.1 to 8.0, while that seem to change the target platform after I reloaded the project it broke a bunch of stuff.

For now it seems like you have to keep both VS 2012 and VS 2013 side by side if you will be doing any windows store app development and want to target 8.0. VS 2013 project templates for windows store apps are designed to work with Windows 8.1 only. I don’t like that I have to have two versions of VS in my dev machine but it is what it is. If you have any work around or suggestions, please post a comment



Sending email from windows store apps using SendGrid Web Api and HTTP Client

One of the things you will notice when working on windows store applications is that there isn’t any api’s within windows runtime or .NET for Windows Store apps for sending emails. You can of course have a hyperlink button with navigateUri set to for ex. to send emails using the mail client installed. What if you want to attach a file or generate email in a specific format or have a cool UI in your app for allowing users to contact you as app developer? In this post I will walk through how I used SendGrid and HTTP client to accomplish just that. One thing I want to point out that the C# SDK from SendGrid cannot be used in windows store apps due to references to API’s and libraries that aren’t simply supported in windows store apps. This is the primary reason why I chose to use HTTP client and roll my own service that Views and ViewModels within my app can consume.

If you are not familiar with SendGrid Web Api check out this awesome documentation from SendGrid team

If you have never used SendGrid before you can check out more info at their site, Its super easy to sign up. Best part is SendGrid is also available for use within your cloud applications in Windows Azure. Really a great example of an excellent online service, cloud enabled and you can use it from anywhere, web, devices, etc.

Define a new class called EmailMessage in your windows store project as shown below, basically this class will be used as a data object when sending emails from your app using email service that we will define later.

internal class EmailMessage


    public string From { get; set; }

    public string FromEmail { get; set; }

    public string To { get; set; }

    public string ToEmail { get; set; }

    public string Subject { get; set; }

    public string Body { get; set; }

    public IReadOnlyList<StorageFile> Attachments { get; set; }


Next we define an interface called IEmailService, see below

interface IEmailService


    string ApiUser { get; }

    string ApiKey { get; }


    Task<String> SendEmail(EmailMessage message);


Now we’ll define the EmailService class which will implement the IEmailService interface. In this class I defined constants to hold the SendGrid web api parameter names.
In the constructor I set the ApiUser and ApiKey property by reading values stored in Resource file. You probably should store these in a more secure location as one could easily reflect the assembly and see the values from Resource files.

SendEmail Implementation

The implementation for SendEmail method is quite straight forward, see the code below. Below Implementation also supports sending attachments, EmailMessage class has a property which is a read only collection of StorageFiles, this can be set from calling method if out going email message requires file attachments.

public async Task<string> SendEmail(EmailMessage message)


   HttpClient httpClient = null;

   string responseData = string.Empty;



       using (var postData = new MultipartFormDataContent())


           var subjectContent = new StringContent(message.Subject);

           subjectContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")


               Name = SubjectParam



           var bodyContent = new StringContent(message.Body);

           bodyContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")


               Name = HtmlParam



           //setup api key and api user param

           var apiUserContent = new StringContent(ApiUser);

           apiUserContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")


               Name = ApiUserParam



           var apiKeyContent = new StringContent(ApiKey);

           apiKeyContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")


               Name = ApiKeyParam



           var fromNameContent = new StringContent(message.From);

           fromNameContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")


               Name = FromNameParam



           var fromContent = new StringContent(message.FromEmail);

           fromContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")


               Name = From



           StringContent toContent = new StringContent(message.ToEmail);

           toContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")


               Name = ToParam



           var toNameContent = new StringContent(message.To);

           toNameContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")


               Name = ToNameParam



           if (message.Attachments.Count() > 0)


               foreach (var attachment in message.Attachments)


                   Stream fs = await attachment.OpenStreamForReadAsync();

                   postData.Add(AddFile(fs, FilesParam, attachment.Name));



           string fullUrl = string.Format("https://{0}{1}", SendGridHost, Uri);

           httpClient = new HttpClient();

           HttpResponseMessage response = await httpClient.PostAsync(new Uri(fullUrl), postData);

           using (HttpContent content = response.Content)


               responseData = await content.ReadAsStringAsync();


           if (response.StatusCode != System.Net.HttpStatusCode.OK)

               throw new Exception(responseData);


       return responseData;




       if (httpClient != null)




Handling File Attachments

Helper method for file attachments for emails.

private StreamContent AddFile(Stream stream, string name, string fileName)


    var fileContent = new StreamContent(stream);

    fileContent.Headers.ContentDisposition = new ContentDispositionHeaderValue("form-data")


        Name = string.Format("{0}[{1}]", name, fileName),

        FileName = fileName


    fileContent.Headers.ContentType = new MediaTypeHeaderValue("application/octet-stream");

    return fileContent;



Sending Email

Here is an example of sending email using the service from your windows store app, I’m using ServiceLocator to get an instance of email service.

IEmailService emailService = ServiceLocator.Current.GetInstance<IEmailService>();

await emailService.SendEmail(new EmailMessage()


    To = "Someone",

    ToEmail = "",

    From = "",

    FromEmail = "",

    Body = "Sending Email from Windows Store apps",

    Subject = "Sending Email from Windows Store apps",

    Attachments = new ReadOnlyCollection<StorageFile>(attachments)


I will be publishing a Sample to MSDN code sample site and will update this post with links

Hope this helps



Annoying experience with TFS Online

Hope this post doesn’t come across as a rant but just wanted to share the experience I had with tfsonline service, hopefully someone in charge of this service will see this and take some action.

If you are not familiar with tfsonline, simplistic way to think about it is that its a hosted TFS offering completely managed by Microsoft. As an MSDN subscriber you get this pretty much free of cost. I use it for all my personal projects.

Now to main reason for this post, I was trying to help out a friend (Fabian) with an issue and he granted me access to his project in TFS Online. After he granted me access I received following email from the service



I clicked on “Accept the Invitation” link and it took me to, I sign to the service using my live id credentials and I get following screen


At this point I’m wondering where on earth is Fabian’s project that he just granted me access to? It would have been very helpful if the above UI showed that, Unfortunately as you can see from screen shot it doesn’t.

If I know Fabian’s TFS service address I could simply connect to his project via Web or from VS using the URL and signing in with my live ID.

Hope Microsoft will fix this soon and include the projects I have access to in the screen above which will allow me to connect to another users project because currently it’s quite confusing and requires a manual step



List of windows store app bar button styles

By default when you create Windows Store Application using the Visual Studio project templates, Visual Studio adds a XAML resource dictionary (“StandardStyles.xaml”) file under common folder, this file contains styles that really simplify application development and ships with a set of App Bar button styles. These styles are by default commented, you can simply uncomment the ones you are using in your project.

I’ve listed each style here in the post with a visual image so you understand what’s available to use within your application and know how it looks like visually, If for some reason you don’t like the default text used in these buttons you can simply edit the property setter value named “AutomationProperties.Name”, defined in the StandardStyles.xaml file. Hopefully this will save you some time

To use these buttons simply add a button control and set the style property, see example below

      Style="{StaticResource RefreshAppBarButtonStyle}" />



RefreshAppBarButtonStyle image
SkipBackAppBarButtonStyle image
SkipAheadAppBarButtonStyle image
PlayAppBarButtonStyle image
PauseAppBarButtonStyle image
EditAppBarButtonStyle image
SaveAppBarButtonStyle image
DeleteAppBarButtonStyle image
DiscardAppBarButtonStyle image
RemoveAppBarButtonStyle image
AddAppBarButtonStyle image
NoAppBarButtonStyle image
YesAppBarButtonStyle image
MoreAppBarButtonStyle image
RedoAppBarButtonStyle image
UndoAppBarButtonStyle image
HomeAppBarButtonStyle image
OutAppBarButtonStyle image
NextAppBarButtonStyle image
PreviousAppBarButtonStyle image
FavoriteAppBarButtonStyle image
PhotoAppBarButtonStyle image
SettingsAppBarButtonStyle image
VideoAppBarButtonStyle image
DownloadAppBarButtonStyle image
MailAppBarButtonStyle image
SearchAppBarButtonStyle image
HelpAppBarButtonStyle image
UploadAppBarButtonStyle image
EmojiAppBarButtonStyle image
TwoPageAppBarButtonStyle image
LeaveChatAppBarButtonStyle image
MailForwardAppBarButtonStyle image
ClockAppBarButtonStyle image
SendAppBarButtonStyle image
CropAppBarButtonStyle image
RotateCameraAppBarButtonStyle image
PeopleAppBarButtonStyle image
ClosePaneAppBarButtonStyle image
OpenPaneAppBarButtonStyle image
WorldAppBarButtonStyle image
FlagAppBarButtonStyle image
PreviewLinkAppBarButtonStyle image
GlobeAppBarButtonStyle image
TrimAppBarButtonStyle image
AttachCameraAppBarButtonStyle image
ZoomInAppBarButtonStyle image
BookmarksAppBarButtonStyle image


ProtectedDocumentAppBarButtonStyle image
PageAppBarButtonStyle image
BulletsAppBarButtonStyle image
CommentAppBarButtonStyle image
Mail2AppBarButtonStyle image
ContactInfoAppBarButtonStyle image
HangUpAppBarButtonStyle image
ViewAllAppBarButtonStyle image
MapPinAppBarButtonStyle image
PhoneAppBarButtonStyle image
VideoChatAppBarButtonStyle image
SwitchAppBarButtonStyle image
ContactAppBarButtonStyle image
RenameAppBarButtonStyle image
PinAppBarButtonStyle image
MusicInfoAppBarButtonStyle image
GoAppBarButtonStyle image
KeyboardAppBarButtonStyle image
DockLeftAppBarButtonStyle image
DockRightAppBarButtonStyle image
DockBottomAppBarButtonStyle image
RemoteAppBarButtonStyle image
SyncAppBarButtonStyle image
RotateAppBarButtonStyle image
ShuffleAppBarButtonStyle image
ListAppBarButtonStyle image
ShopAppBarButtonStyle image
SelectAllAppBarButtonStyle image
OrientationAppBarButtonStyle image
ImportAppBarButtonStyle image
ImportAllAppBarButtonStyle image
BrowsePhotosAppBarButtonStyle image
WebcamAppBarButtonStyle image
PicturesAppBarButtonStyle image
SaveLocalAppBarButtonStyle image
CaptionAppBarButtonStyle image
StopAppBarButtonStyle image
ShowResultsAppBarButtonStyle image
VolumeAppBarButtonStyle image
RepairAppBarButtonStyle image
MessageAppBarButtonStyle image
Page2AppBarButtonStyle image
CalendarDayAppBarButtonStyle image
CalendarWeekAppBarButtonStyle image
CalendarAppBarButtonStyle image
CharactersAppBarButtonStyle image
MailReplyAllAppBarButtonStyle image
ReadAppBarButtonStyle image
LinkAppBarButtonStyle image
AccountsAppBarButtonStyle image
ShowBccAppBarButtonStyle image
HideBccAppBarButtonStyle image
CutAppBarButtonStyle image
AttachAppBarButtonStyle image
PasteAppBarButtonStyle image
FilterAppBarButtonStyle image
CopyAppBarButtonStyle image
Emoji2AppBarButtonStyle image
ImportantAppBarButtonStyle image
MailReplyAppBarButtonStyle image
SlideShowAppBarButtonStyle image
SortAppBarButtonStyle image
ManageAppBarButtonStyle image
AllAppsAppBarButtonStyle image
DisconnectDriveAppBarButtonStyle image
MapDriveAppBarButtonStyle image
NewWindowAppBarButtonStyle image
OpenWithAppBarButtonStyle image
ContactPresenceAppBarButtonStyle image
PriorityAppBarButtonStyle image
UploadSkyDriveAppBarButtonStyle image
GoToTodayAppBarButtonStyle image
FontAppBarButtonStyle image
FontColorAppBarButtonStyle image
Contact2AppBarButtonStyle image
FolderppBarButtonStyle image
AudioAppBarButtonStyle image
PlaceholderAppBarButtonStyle image


SetLockScreenAppBarButtonStyle image
SetTitleAppBarButtonStyle image
CcAppBarButtonStyle image
StopSlideShowAppBarButtonStyle image
PermissionsAppBarButtonStyle image
HighlightAppBarButtonStyle image
DisableUpdatesAppBarButtonStyle image
UnfavoriteAppBarButtonStyle image
UnPinAppBarButtonStyle image
OpenLocalAppBarButtonStyle image
MuteAppBarButtonStyle image
ItalicAppBarButtonStyle image
UnderlineAppBarButtonStyle image
BoldAppBarButtonStyle image
MoveToFolderAppBarButtonStyle image
LikeDislikeAppBarButtonStyle image
DislikeAppBarButtonStyle image
LikeAppBarButtonStyle image
AlignRightAppBarButtonStyle image
AlignCenterAppBarButtonStyle image
AlignLeftAppBarButtonStyle image
ZoomAppBarButtonStyle image
ZoomOutAppBarButtonStyle image
OpenFileAppBarButtonStyle image
OtherUserAppBarButtonStyle image
AdminAppBarButtonStyle image
StreetAppBarButtonStyle image
MapAppBarButtonStyle image
ClearSelectionAppBarButtonStyle image
FontDecreaseAppBarButtonStyle image
FontIncreaseAppBarButtonStyle image
FontSizeAppBarButtonStyle image
CellphoneAppBarButtonStyle image
ReshareAppBarButtonStyle image
TagAppBarButtonStyle image
RepeatOneAppBarButtonStyle image
RepeatAllAppBarButtonStyle image
OutlineStarAppBarButtonStyle image
SolidStarAppBarButtonStyle image
CalculatorAppBarButtonStyle image
DirectionsAppBarButtonStyle image
TargetAppBarButtonStyle image
LibraryAppBarButtonStyle image
PhonebookAppBarButtonStyle image
MemoAppBarButtonStyle image
MicrophoneAppBarButtonStyle image
PostUpdateAppBarButtonStyle image
BackToWindowAppBarButtonStyle image
FullScreenAppBarButtonStyle image
NewFolderAppBarButtonStyle image
CalendarReplyAppBarButtonStyle image
UnsyncFolderAppBarButtonStyle image
ReportHackedAppBarButtonStyle image
SyncFolderAppBarButtonStyle image
BlockContactAppBarButtonStyle image
SwitchAppsAppBarButtonStyle image
AddFriendAppBarButtonStyle image
TouchPointerAppBarButtonStyle image
GoToStartAppBarButtonStyle image
ZeroBarsAppBarButtonStyle image
OneBarAppBarButtonStyle image
TwoBarsAppBarButtonStyle image
ThreeBarsAppBarButtonStyle image
FourBarsAppBarButtonStyle image



HOW-TO: Generate hash in windows store apps

This post shows how to generate hash using SHA1 algorithm in windows store apps, useful if your app makes calls to rest api’s that require app to pass an api signature as header or querystring


Import following namespaces 

using Windows.Security.Cryptography;
using Windows.Security.Cryptography.Core;
using Windows.Storage.Streams;
Convert the string to binary
IBuffer buffer = CryptographicBuffer.ConvertStringToBinary(text, BinaryStringEncoding.Utf8);

Create the hash
HashAlgorithmProvider provider = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha1);

//hash it

IBuffer hash = provider.HashData(buffer);

Create a base64 encoded string


Base64 encoded string can be used as API signature


You can wrap this functionality into a nice helper class and reuse, see full code below 

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

using Windows.Security.Cryptography;

using Windows.Security.Cryptography.Core;

using Windows.Storage.Streams;



    internal static class Helper


        public static string ComputeHash(string text)


            string base64Encoded = string.Empty;

            IBuffer buffer = CryptographicBuffer.ConvertStringToBinary(text, BinaryStringEncoding.Utf8);

            HashAlgorithmProvider provider = HashAlgorithmProvider.OpenAlgorithm(HashAlgorithmNames.Sha1);

            //hash it

            IBuffer hash = provider.HashData(buffer);

            base64Encoded = CryptographicBuffer.EncodeToBase64String(hash);

            return base64Encoded;







When typing PowerShell ISE in start screen opens in PowerShell command line and not PowerShell ISE

I recently encountered a windows 8 bug that took me a bit to figure out the exact root cause, posting it here incase anyone run into this in future.

Subject of the post basically sums up the issue. Root cause was in my roaming profile I had a Shortcut named “PowerShell ISE” which was referring the command line powershell instead of powershell_ise.exe.

How the shortcut got created in my roaming settings completely beats me, if you encounter the same issue you can simply check “C:\Users\[windows logon]\AppData\Roaming\Microsoft\Windows\Start Menu\Programs” for a shortcut named “PowerShell ISE” and either delete the shortcut or update in properties to point to powershell_ise.exe instead of powershell.exe

Hope that saves someone else time in future



Recovering data from an unattached content database using PowerShell

One of the really nice IT Pro features in SharePoint, introduced back in SharePoint Server 2010 is a feature called “recover data from an unattached content database”. It allows us to perform a granular recovery of content from an unattached content database (content database restored from a backup). I’m sure many of you are already familiar with this feature and have probably seen various demos etc. so I’m not going to re-hash it here.

Feature is pretty well documented here, unfortunately the problem is if you pay close attention to this TechNet article especially where they talk about how to recover data from an unattached content database using PowerShell you will find that it is not complete, in fact not even close.

While it is a pretty nice feature there are too many moving parts, what I mean is you have to restore the database first, then you have to export the list out of unattached content database using Central Administration UI, then you have to run Import-SPWeb PowerShell to actually import the list into the site where you want to recover the deleted list.

I created a PowerShell to automate the exporting of list from an unattached content database and importing to the site, you still need to restore content database from a backup prior to running the script. You can get the script from here



When Service Account Password in AD and SharePoint Gets out of sync

This can happen sometimes when service account passwords are changed in AD and Managed Account passwords stored in SharePoint are now out of sync. Fixing this is fairly easy, not sure if the documentation on this is pretty clear but this may help others

Fortunately we can fix this with a simple PowerShell


[string] $Account

$cred = Get-Credential($Account)

Write-Host -ForegroundColor White "Updating Stored Managed Account Password"
Set-SPManagedAccount -UseExistingPassword -Identity $Account -ExistingPassword $cred.Password