Vasu Ashok
Vasu Ashok

Reputation: 1413

Getting Started WP7 App development without XAML using Visual Studio 2010 C#

Am Newbie for Windows Phone Development and Using Visual Studio 2010 C#.Design parts are done using XAML File in VS 2010.my intend to do code behind in .CS File alone.

With help of main xaml Dynamically i have created grid ,button,text boxes and so on.it works perfectly

But Now i want to remove XAML completely and do all Work by code behind in .cs file Alone. please suggest some tutorial or getting started documentation for dynamic coding.

correct me if anything wrong...Thanks in advance

Upvotes: 0

Views: 781

Answers (3)

Jan Slodicka
Jan Slodicka

Reputation: 1515

In general nearly all that can be done in Xaml can be done in C#, too. However, there are important exceptions.

As an example take DataTemplate class and look into its properties. You will find zero and you won't find any class ContentAttribute either. Despite that you can use DataTemplate in Xaml to specify the template content. This is an example of a Xaml code that cannot be done in C#. (In this case the reason is that Silverlight - unlike WPF - hides DataTemplate implementation. Only the Xaml processor has the privilege to see it, C# programmers are out of luck.)

The other guys argue that porting Xaml into C# will produce messy code. Well, I cannot quite agree. I would say it conditionally, i.e. it depends on your ability to format the code.

I made it several times. Here is an example of a middle complexity. Those who take the effort of comparing original Xaml code (PerformanceProgressBar code) to the described C# code will have to admit that

  • (This) C# code is shorter
  • (This) C# code is easier to read

And if you invest even more effort you will have to acknowledge that

  • (Any) C# code is faster

Ok, I don't want to argue against Xaml. It helps to isolate UI and once you'll learn its language it becomes a natural tool that will help you. All I wanted to say is that Xaml is not the only way of doing UI and not even necessarily the best one. People were able to creeate nice UI in the pre-Xaml era, too.

Upvotes: 3

Rafal Spacjer
Rafal Spacjer

Reputation: 4918

I think this is a bad idea to not use xaml in Silverlight application.

First of all your code to create GUI will be extremal big and complicated, so maintenance of it will be a nightmare.

Second I don't understand what do you mean that you can't predicate views counts. Are you sure of it? Please describe what do you want to do? In xaml you can show and hide some parts of the view, you can use different styles and make lots of things...

An the last you should use xaml because you can use Bled then - to create animation and any sort of visual effects for your app.

Upvotes: 1

Den
Den

Reputation: 16826

Even with an "unpredicted" number of views, you will still need the basic structure - the "skeleton" that will hold everything together. A better approach here would be using the MVVM pattern to separate the UI from the data and simply modify the data while keeping the fundamental structure. It appears to me that you are taking the wrong path there.

Due to the nature of Silverlight development, relying solely on code-behind content is pretty much deifying the SL architecture.

Upvotes: 2

Related Questions