Subscribe to Feed

Posts Tagged ‘C#

If you use CameraCaptureUI, the user will be prompted for permission automatically. But the DeviceInformation API does not indicate whether or not the user has granted permission.
Here is sample class that you can use to see whether a camera is available, with support for data binding
 

using Common;
using System.Collections.Generic;
using System.Linq;
using Windows.Devices.Enumeration;
 
 
namespace Helpers
{
[...]

It is very easy to check if the user has enabled Location Services (GPS) in Windows Phone.
GeoCoordinateWatcher g = new GeoCoordinateWatcher(GeoPositionAccuracy.High);
g.Start();
if (g.Permission == GeoPositionPermission.Denied)
{
// then we know it is off, else we assume it is on
// Show message box..
}


// Ensure the you properly dispose the watcher
g.stop();
g.Dispose();
One catch here is [...]

When you compile your windows phone app, it might build fine but throw an “unspecified error” when you try to deploy your app either onto your phone or to the emulator. The most probable reason that causes this is that there is style incompatibility in your xaml that the parser failed to resolve.
To fix the [...]

It is very easy to convert a string to stream and vice versa in .Net.
Converting String to Stream:
MemoryStream stream = new MemoryStream();
StreamWriter writer = new StreamWriter(stream);
writer.Write(myString);
writer.Flush();
 
if you already know the encoding of your string, you can also use
 
byte[] tempByteArray = Encoding.ASCII.GetBytes(myString);
MemoryStream stream = new MemoryStream(tempByteArray);
 
Converting Stream to String:
 
StreamReader reader = new StreamReader(stream);
stream.Position = 0;
string [...]

In a .Net 4.0 or later web application you may receive an error similar to
“The configuration section yoursection cannot be read because it is missing a section declaration”

when you try to get the web configuration information using Microsoft.Web.Administration.ServerManager API even when your web.config file looks alright and you do declare “yoursection” in the [...]

One of the caveats with using RenderControl to spit out the HTML content that an ASP.Net server control generates is that any server control that renders client side JavaScript raises a http exception when rendering the content of the control to a HtmlTextWriter. There are couple of ways you can bypass this in .Net. One [...]

On windows Phone, you can easily use templates to change the default UI for most of the controls. In this post, I am giving an example of how to change the color of a scroll bar in a list box. The template I provided here is extensive and can use used to change many things [...]

Accelerometer; Simulating accelerometer data in the Windows Phone 7 Emulator
http://blogs.silverarcade.com/silverlight-games-101/27/silverlight-simulating-accelerometer-data-in-the-windows-phone-7-emulator/

Animation; Ptorr Slides, Video and Code (Page Turn animation etc.)
http://blogs.msdn.com/ptorr/archive/2010/03/18/slides-video-and-code.aspx

Audio; Audio Recording in WP7
http://mobileworld.appamundi.com/blogs/peterfoot/archive/2010/03/26/audio-recording-in-wp7.aspx

Comms; Accessing WCF Data Services from WP7 CTP
http://blogs.msdn.com/priozersk/archive/2010/03/19/accessing-wcf-data-services-from-wp7-ctp.aspx

Comms; Calling Web Services with Silverlight 2 (general example)
http://timheuer.com/blog/archive/2008/03/14/calling-web-services-with-silverlight-2.aspx

DB; Siaqodb on [...]

The other day I was struggling to write a small LINQ query, and after searching for a while I found this awesome page on MSDN which has about 101 LINQ samples. The samples cover most of the basic LINQ stuff that one would need. Here is the location
101 LINQ Samples: @ http://msdn.microsoft.com/en-us/vcsharp/aa336746.aspx
 
-CTRL+F5

One of the requirements in publishing media related apps for windows phone is that you have to prompt user a message asking his permission to continue if a media file is already being played in the background.
Here is the actual text from the app requirements
6.5.1 Initial Launch Functionality When the [...]


 

 

Recent Comments