Skip to main content

Posts

Showing posts from May, 2011

Silverlight Panels: How to use Canvas Layout in Silverlight?

Silverlight Panels: How to use Canvas Layout in Silverlight?In this article let us learn how to use Canvas Layout panelin a Silverlight application. CanvasLayout panelis another most useful panel we ever use in Silverlight. Using this we can place any content any where inside the canvas. Canvas is mostly useful whenever we want place any objects in layered fashion. We can put our content in specific location by providing absolute left and top position to Canvas Layout
As usual, open visual studio and select Silverlight project. We can notice that there is a Grid layout in our MainPage.xaml.  Remove the default Grid layout and just drag and drop the Canvas Layout into our application. The code for this looks like as
<Canvas Name="canvas1"> <Rectangle x:Name="rectFirst" Fill="Blue" Height="100" Width="100" /> <Rectangle x:Name="rectSecond" Fill="red" Height="100" Width="100"/> </C…

“Not able to view the solution file in Visual Studio” – Hide and Show solution file in Visual Studio

Sometime you may came across with this problem that, you are not able to view the solution file in Visual Studio though you have solution file in proper place and the file physically exists in solution folder . You may just wonder why you are not able to view the solution file. Yeah, it could be some missing settings with in visual studio.If you create any Visual Studio Project, by default you will get below view in Solution Explorer ( Solution file and the Project files associated with in solution ).More Detail at Original Source

How do you convert a string into an enum?

How do you convert a string into an enum? it's one of those methods that you can never find when you're looking for it, but once discovered it seems blindingly obvious: object Enum.Parse(System.Type enumType, string value, bool ignoreCase);So you can write the following kind of code: enum Colour { Red, Green, Blue } // ... Colour c = (Colour) Enum.Parse(typeof(Colour), "Red", true); Console.WriteLine("Colour Value: {0}", c.ToString()); // Picking an invalid colour throws an ArgumentException. To // avoid this, call Enum.IsDefined() first, as follows: string nonColour = "Polkadot"; if (Enum.IsDefined(typeof(Colour), nonColour)) c = (Colour) Enum.Parse(typeof(Colour), nonColour, true); else MessageBox.Show("Uh oh!");What a time saver - thanks

Windows Phone 7 Tutorials Jump Start with Mango - 2 - Know more about Page

Windows Phone 7 Jump Start with Mango - 2 - Know more about PageIn my previous post, we discussed on how to create a Windows Phone 7 application and what are the different parts of the MainPage.xaml. We also created a small and simple HelloWorld application as the quick start. I guess, now we are comfortable to create a basic application with a good UI (if you already know how to design a XAML page).   It's time to explore more in depth about the page. In this post, we will discuss about the base class called "Page". Read to know more about it.     Introduction to Page Like "MainPage.xaml", every Windows Phone 7 page inherits from "PhoneApplicationPage" by default, which is part of Microsoft.Phone.Controls namspace. PhoneApplicationPage itself derives from the base class called "Page", part of System.Windows.Controls namspace. Every "Page" is nothing but a derived class of UserControl and if you are already familiar with the UserCo…

Classes for fetching and parsing XML or JSON via HTTP

IntroductionIn my experience, "fetching data via HTTP" is probably the second most common task that iOS applications perform after "displaying a list of things in a table". Since I wrote a recent post showing how I handle display in tables, showing my reusable classes for fetching via HTTP seemed like a reasonable follow up.As with the post on UITableView management, this post is all about trying to make the HTTP fetching, handling and processing as simple and reusable as possible.What I hope to demonstrate is that even though the Cocoa API makes it look like you need to boltNSURLConnection delegate methods onto your own classes every time you need a network connection, it doesn't mean that you actually need to do all this work every time you need a network connection. For the most common tasks like this, you should develop your own, reusable approaches that you like, that serve your needs and that make new code easier.There are lots of alternative approaches …

How to validate a DropdownList - ListBox.

Original SourceIn this article, we are going to learn how to validate a DropdownList/ListBox.
IntroductionNormally we validate a TextBox to make it mandatory by usingRequiredFieldValidator, however sometimes we need to validate aDropDownList/ListBox so that user doesn't select the default selected item from it. To validate a DropDownList/ListBox as a mandatory field so that user has to select an item other than the default selected item we can still useRequiredFieldValidator however with one extra property.Let's see this with example. First create a .aspx page and paste below code.ASPX PAGE:Select age:<asp:dropdownlistid="dropDownAge"runat="server"><asp:ListItemText="Select Age"Value="0"/><asp:ListItemText="18"Value="18"/><asp:ListItemText="19"Value="19"/>

Windows Phone 7 Jump Start with Mango - 1 - Creating a Hello World Application

Windows Phone 7 Jump Start with Mango - 1 - Creating a Hello World ApplicationRecently thought to take some break from core Silverlight programming and start learning something new. As I will be working on Silverlight in office, hence decided to start exploring Windows Phone 7 in my off time. Though, it is also in Silverlight, but there we can learn something new apart from the actual Silverlight development. Now onwards, I will write about Windows Phone 7 programming and whatever I will explore, will post here in my blog.   Jump started with my first exploration to create a "Hello World" application in Windows Phone 7.1 (Mango) public Beta. This is the first post of the series. As a beginner I will be contributing to the series and if something that I can improve in any of the posts/demos, please let me know by providing your inputs using the Comment box. Hope this series will help the beginners to learn about it.     Prerequisite If you are new to Windows Phone 7, you need…

User interface strings in Cocoa

Introduction (the wrong way)Putting a text string in your user interface is not a difficult thing to do on a technical level. In code, filling in text can be as simple as setting the text property of a UILabel to a literal string: someUserInterfaceLabel.text = @"Text to display";(This code is for an iOS UILabel. On Mac OS X, you would set the stringValue property of anNSTextField but otherwise the step is the same.)While this will work, you should never set a user interface string this way.More at Original Source

Tips & Tricks for conditional iOS3, iOS3.2 and iOS4 code

A project or target that supports multiple versions of iOSTo make an application target that runs on multiple versions of iOS is relatively simple:Set the "Base SDK" in your projects settings to the newest version number of iOS whose features you may want.Set the "iPhone OS Deployment Target" to the oldest version number of iOS that you will supportHowever, getting the target settings correct is the easy part of the problem. The hard part is using new features on newer iOS versions without breaking the app on older versions. Running in the 3.1.3 simulator
Detail at Original Source

A ZoomingViewController to animate a UIView to fullscreen

ZoomingViewController is a class you can attach to any existing view that will let you zoom the view to fullscreen with a single tap, rotate the view while in fullscreen by rotating the device and tap to return to the original inline state. IntroductionThe ZoomingViewController class in this week's sample project handles the zooming in the following sample app: The animation between the inline and fullscreen states is smooth and you can rotate the device in fullscreen to rotate the view.You can attach the ZoomingViewController to any view to add this behavior.Source

Size-to-Fit Text in UITextView (iPhone)

The UITextView is a very useful view. You're able to show and interact with large amounts of text. However, I recently found the need to size the UITextView in Interface Builder to fit nicely in a pre-layed out interface. Well, low-and-behold the client I was working for started sending large amounts of text that was to be displayed here. We didn't want scrolling but needed to display all the text. So, we needed to resize the text until it would fit and all would be displayed. Below is a very simple way of resizing the text in the UITextView to fit within its current bounds.At some point define the max size you want the font to be. I typically put this in my .h file #define kDefaultFontSize 24.0Then in your .m file where you add the text to the UITextView you would place something like: myTextView.text = @"Some long string that will be in the UITextView"; myTextView.font = [UIFont systemFontOfSize:kDefaultFontSize]; //setup text resizing check here if (myTextView.c…

Key inputs to avoid Apple’s iOS app rejection

An app idea or product app takes much of time and money investment to get into app world existence. The major hurdle to it's success could be Apple's review process. There can be numerous reasons for Apple's rejections for your app. With our superior knowledge of iOS apps development since the day Apple launched their SDK, we are able to gain valuable insights into Apple's review process. This will help: 1. Developers to save their precious time and efforts. 2. Let you plan for a better user experience which is the key reason behind all the app store guidelines. There are few key points which every iPhone/iPad developer should know when developing an app for Apple devices.Key things to avoid Apple's app rejection:1. Bugs/Crashes- The most common reason for any app to get rejected are freezing and frequent crashes. Make sure you test it on multiple devices, different OS versions and specifically under varying network conditions. Peer-to-peer reviews/testing done by…

Grouping Records in Silverlight DataGrid using PagedCollectionView

Do you work with Silverlight DataGrid and want to group your records inside the DataGrid in a proper manner? If so, this article is for you. Here we will learn about data grouping inside a DataGrid. In this article, we will learn how to group data inside a Grid. We will discuss all these steps-by-step and with proper images, so that, you can understand it very easily. The full source code has been attached. You can freely download it and that will be more helpful for you to understand. Read the complete article to learn it.
Detail here at Original Source

Collection Initializers in .NET

Many of you have used property initializers in your code. Object initializers and property initializers are common operations of every program. But do you know, .NET supports Collection initilization directly for all IEnumerable objects ? In this post lets take a brief introduction of Collection Initializers in .NET.Suppose you want to create an array which holds some values, you might write :string[] myarray = {"Abhishek", "Abhijit", "Atul", "Jaberson" };Oh, it works. myarray is going to initialize with values specified inside the curl braces.You might think, this is very common syntax that we all know from basic programming languages. But yet, C# puts this further, lets demonstrate :List mylst = {1,2,3,4,5};Yes even this works as well. Actually curl braces produces an IEnumerable which you can cast to any custom collection type.You can even use this syntax to do like this :List mylst = { 1, 2, x * 20, this.GetInt(), 44 };The 3rd value will be…

How to store custom objects in web.config ?

In this Post, I am going to discuss about web.config. Normally in our daily life, we used to have some data inappSettings section of web.config and read it when required. That is in string form. But there are lot more than this. We can update the data in web.config programmatically as well .Now another main point is, we can store some object of custom type in web.config as well, which we normally don't do it. But this can be very useful in several scenarios.
Have anyone tried to update some value or add some value in web.config? W'll have brief discussion on this. First, This is very common to have some constant data atappSettings section of web.config and read it whenever required. So how to read this ( for beginners). //The data is stored in web.config as <appSettings> <add key="WelcomeMessage" value="Hello All, Welcome to my Website." /> </appSettings> // To read it string message = ConfigurationManager.AppSettings["WelcomeMess…