C# – Get mac address in Universal Apps

Hmmm I wrote something but I didn’t tested it on mobile device because I don’t have any at the moment but I tested it on my PC and Windows Mobile 10 emulator. public static class AdaptersHelper { const int MAX_ADAPTER_DESCRIPTION_LENGTH = 128; const int ERROR_BUFFER_OVERFLOW = 111; const int MAX_ADAPTER_NAME_LENGTH = 256; const int MAX_ADAPTER_ADDRESS_LENGTH … Read more

Read text file in project folder in Windows Phone 8.1 Runtime

If you want to read a file from your project you can for example do it like this: string fileContent; StorageFile file = await StorageFile.GetFileFromApplicationUriAsync(new Uri(@”ms-appx:///example.txt”)); using (StreamReader sRead = new StreamReader(await file.OpenStreamForReadAsync())) fileContent = await sRead.ReadToEndAsync(); Also please ensure that you have set the Build Action of your file as Content (it should be … Read more

Is it possible to send Toast notification from console application?

At first you need to declare that your program will be using winRT libraries: Right-click on your yourProject, select Unload Project Right-click on your yourProject(unavailable) and click Edit yourProject.csproj Add a new property group:<targetplatformversion>8.0</targetplatformversion> Reload project Add reference Windows from Windows > Core Now you need to add this code: using Windows.UI.Notifications; and you will … Read more

AdaptiveTrigger and DataTemplate

Try wrapping your DataTemplate inside a UserControl like this – <DataTemplate> <UserControl> <Grid> <VisualStateManager.VisualStateGroups> … </Grid> </UserControl> </DataTemplate> Looks like any Control that has got a Content property will work. That’s why UserControl works, so does a ContentControl. So if you replace the UserControl with a ContentControl and give it an empty Style. It should … Read more

Photo capture on Windows Store App for Windows Phone

In WP8.1 Runtime (also in Silverlight) you can use MediaCapture. In short: // First you will need to initialize MediaCapture Windows.Media.Capture.MediaCapture takePhotoManager = new Windows.Media.Capture.MediaCapture(); await takePhotoManager.InitializeAsync(); If you need a preview you can use a CaptureElement: // In XAML: <CaptureElement x:Name=”PhotoPreview”/> Then in the code behind you can start/stop previewing like this: // start … Read more

Encoding.GetEncoding can’t work in UWP app

We need to use the CodePagesEncodingProvider to register extended encodings included in that specific provider. See CodePagesEncodingProvider Class Encoding.RegisterProvider(CodePagesEncodingProvider.Instance); Encoding.GetEncoding(“windows-1254”); Ref https://msdn.microsoft.com/en-us/library/system.text.encodingprovider(v=vs.110).aspx The .NET Framework Class Library provides one static property, P:System.Text.CodePagesEncodingProvider.Instance, that returns an EncodingProvider object that makes the full set of encodings available on the desktop .NET Framework Class Library available to .NET … Read more