Part 4: Introduction to XAML

Sign in to queue

The Discussion

  • User profile image
    QuocTruong

    Thanks you. This lesson very helpful.

  • User profile image
    Muhammad​Faizan

    I find XAML more easy than HTML and CSS because you can design and create on the same Mark up, which is not the case with HTML !! or not favorable to do so !!

  • User profile image
    Yaman Maarrawi

    Thanks BOB! Is it possible if I relied on XAML instead of C#?

  • User profile image
    BobTabor

    @QuocTruong: Thank you!

    @Yaman Maarrawi: I'm not really sure what you're asking.  You will want to do your layout in XAML and respond to events using C#.  So ... rely on both?

     

  • User profile image
    Darko

    Excellent tutorials. Deeply explained and very useful for beginners. Bob you are awesome....I appreciate your work a lot!

  • User profile image
    BobTabor

    @Darko: Thanks Darko!

  • User profile image
    Progr

    Thanks for this lesson. But I am russian and i don't speak english very well and google translate not very correct, but i understend your lessons. Thanks

  • User profile image
    Everton

    Hi BOB!
    Do you have some video about WP8 Development with HTML5?
    Thanks.

  • User profile image
    Rida221

    hey BOB!

    i thought i'd never learn to make windows phone app but thanks to you now it doesnot sound much insane to me!! GOD bless you bro for this initiative (Y) 

  • User profile image
    Clint

    @Everton: WP8 doesn't directly support HTML applications like Windows Store applications currently.  You could do a WebViewer and there are examples out that do that.

  • User profile image
    BobTabor

    @Progr: I'm glad you are able to get some benefit from the videos despite our language differences.  Thank you, my friend.

    @Rida221: Very nice,  thank you!  Glad they helped.

  • User profile image
    Yale

    Very helpful, thank you Bob! What about the style of Buttons in Windows Phone 8? In Windows 8, we can find the App.Resources commented in the App.xaml. But in Windows phone 8, how can I create a appBarButton outside of the AppBar, for example?

  • User profile image
    Clint

    @Yale: you can't leverage an appbarbutton outside the appbar but if you want the look/feel, Coding4Fun Toolkit's round button, that is chances are the closest.  https://channel9.msdn.com/Series/Windows-Phone-8-Development-for-Absolute-Beginners/Part-17-Introducing-the-Coding4Fun-Toolkit

    For styling, check out https://channel9.msdn.com/Series/Windows-Phone-8-Development-for-Absolute-Beginners/Part-13-Styling-Tiles-in-the-LongListSelector

  • User profile image
    Santosh

    Hey Bob,

    As per my knowledge,Windows phone users is very low than Android.Is it useful to learn windows phone.

  • User profile image
    itsaboutcode

    Bob,

    While setting the background color of the button, you used SolidColorBrush class but it's not coming in code intelli-sense. Can you help to fix this issue.

    I have fixed it by comparing my code with the solution provided. Actually we have to use the following name space which was missing from documentation.

    System.Windows.Media;

  • User profile image
    BobTabor

    @Santosh: "The smaller the niche, the bigger the market."  A rich man (actually, the richest man I know) told me that and I've lived by it for the last dozen years.  I see great opportunity where there are millions of users but only thousands of developers.  Just try getting your app noticed in the sea of crap filling the other platform's app stores.  So as far as I'm concerned, yes.

    @itsaboutcode:

    Can you point me to the exact step (above, in the text) where it is missing?  I can make a change.  Thanks!  But just FYI ... in the future, no matter where in .NET examples you see this ... you type in a class name you want to use but it acts like it doesn't recognize it ... this is what professionals do:  they use the shortcut the Ctrl + .   (period) to show the quick-tasks menu under the class name.  It will show the option to add the appropriate using statements.  I do this dozens of time each day and you should too.  Big Smile  Good luck!

  • User profile image
    BolleraSanju

    Execellent Tutorial !! No words to express!!

    I Started with C#... Tutorials  And Now I Am With Windows Phone Development..... Smiley

    Thanks a Tonn BOB!!

  • User profile image
    Gene

    Hi Bob,
    Regarding this line
    myButton.Background = new SolidColorBrush(Colors.Red);
    I am having an error on the SolidColorBrush as it has the red line below it. It is my first day trying to create my first app for Windows 8 and I am not sure where is problem that makes the red line to appear. Hope that you can assist me with this so that I could put colors in the Background of the button. Thanks in advance!

  • User profile image
    Gene

    Oh Bob, No worries about my question. I forgotten to add the using statement System.Windows.Media for that new instant to be able to execute. Thanks once again! Great tutorial!

  • User profile image
    Doctor Who

    Thank you, @Bob and @Clint, for these tutorials. This particular one covered ground that I'm, for the most part already familiar with, but even so there were things I didn't know about. For example, I didn't realize that a xmlns that wasn't named ((e.g.: :x="(something)") is known as the default namespace. Very handy!

    One question I'd like to ask. I'm going to be going along, doing the code as you do it. In my PetSounds project I've got a blue, wavy line under many of the static resources, like PhoneFontFamilyNormal or OhoneTextNormalStyle. If I move my mouse over any of these I get a popup that says:

    Object

    XAML: Resource 'PhoneFontFamilyNormal' is not found

    I don't understand why this should be, after all I am following your instructions, so what am I missing?

  • User profile image
    Clint

    @Doctor Who: do you have resharper installed?

  • User profile image
    Doctor Who

    , Clint wrote

    @Doctor Who: do you have resharper installed?

    Nuts, I've just asked this same question again, but on the next lesson in this series. I'm sorry for duplicating my question.

    No, I don't have resharper installed, but I do have the Telerik tools installed, so maybe that's what's going on.

  • User profile image
    Clint
    @Doctor Who: my gut says that is causing it. Doesn't happen on a "clean" version of vs
  • User profile image
    Clint
    @Doctor Who: like 2 versions ago with resharper, it would do what you are describing.
  • User profile image
    Simon

    What software are you using to record the screen and webcam at the same time? I am interested in creating help videos for my work and this is a much more personable way to create these help files.
    Thank you

  • User profile image
    BobTabor

    @Simon: I'd prefer to answer that offline.  Contact me at bob at you know the rest .net  Smiley

  • User profile image
    Ajay

    I am following the series. But when I type "myButton.Background = new solidcolorbrush(SystemColors.red);", I am getting an error . Can you please help me with that ?

  • User profile image
    Clint

    @Ajay: c# is a strongly cased language which means upper and lower case letters are different.  Also SystemColors, not sure where you got that from.  Code should be:

    myButton.Background = new SystemColorBrush(Colors.Red);

    When you run into trouble, view our sample code for the lesson, those fully compile and run.

  • User profile image
    Rajeev Ulaganathan

    Hi Bob... i'm from India.
    I watched your video and tutorials in pdf, really awesome bob. .
    Its very easy to understand and its amazing. .
    I need a suggestion. Now i know well about Java and Android. . suppose that i learn Windows Mobile App development, will it cause problem to my career in future ?
    Cause My hobby is that always learning something. So Please Help me. .
    What i want to do further ? But i need my future should be brightfull. .

    Thanks in advance . . i hope really someone will help me. .

  • User profile image
    BobTabor

    @Rajeev Ulaganathan: There are two school of thought ... one is to be a generalist, the other, a craftsman.  You can go deep or wide, but not both ... just not enough time.  Personally?  I'm "all in" with Microsoft technologies.  I never even tried to install Eclipse or XCode or anything else.  To me, that didn't help me towards mastery and craftsmanship of Microsoft's API's and technologies.  And even at that, I'm still very narrowly focused within that niche.  So, I would say figure out where you want your career to go and pursue that.  

  • User profile image
    reza farhang

    @Bob tabor : How can i download these video with lower quality?
    iinternet speed in iran is low

  • User profile image
    BobTabor

    @reza farhang:  Yeah, mid-quality is the lowest unfortunately.  This is more of a Channel9 / company issue than a Bob / screencast guy issue.  To get Microsoft's attention, you should add that feedback ... see link in the footer of each page (below).  As of now, you could let it run for a while OR could grab the MP3 and listen along with the text.  I realize that's not idea, but at least you'll be able to get something out of it.  I tried to add screenshots at key moments.  Hope that helps, even if it is an unsatisfying answer.  Sad

  • User profile image
    Shalom29

    Great tutorial...learning a lot with them thumbs up to the team!

  • User profile image
    greenguard

    Awesome work ... thank u so much sir ... this help me alot :)
    Sir can u give me ur email address ???

  • User profile image
    dglambert

    Bob,

    I know it makes more sense to use XAML to write our apps and I am just being nit picky, but the reason you couldn't see both buttons in your example when running our app is because they were overlapped, but rather than messing with the margin couldn't you have just used HorizontalAlignment.Right???

    Devin

  • User profile image
    dglambert

    Also still being picky, if you wanted to write using C# couldn't you have used Object initializers like so..

    Button myButton = new Button { Name = "MeowButton", Height = 200, Width = 200, 
    VerticalAlignment = System.Windows.VerticalAlignment.Top,
    HorizontalAlignment = System.Windows.HorizontalAlignment.Right,
    Background = new SolidColorBrush(Colors.Red), Content = "Meow"};
    ContentPanel.Children.Add(myButton);

    This way you can still have very succinct code.

    Devin 

  • User profile image
    BobTabor

    @dglambert: In all things related to software development, there are many ways to achieve just about any goal.  Smiley  The objective was not to teach how to write succinct code or every possible alternative regarding layout.  The objective is to expose the qualities of XAML.  If you missed that, then I failed you.  I wanted you to see the forrest, not the trees.  

  • User profile image
    Chubbybrett

    @Ajay: I am following the series. But when I type "myButton.Background = new solidcolorbrush(SystemColors.red);", I am getting an error . Can you please help me with that ? 

    I was having the same issue.  Here is how I fixed it.  Looking at the MainPage.xaml.cs file provided with tutorial, I noticed my setup was missing a namspace system.  I was missing line 11 which is: 

    using System.Windows.Media;

    If you add that, the system will now read SolidColorBrush(Colors.Red);

    I am a true beginner and was pulling my hair out but this resolved it.

    Hope this helps.

  • User profile image
    NinjaSpider

    Great tutorial...learning a lot with but can u say how windows phone is better than android?

     

  • User profile image
    BobTabor

    @NinjaSpider: I recently purchased a Samsung Galaxy S4 and an iPhone 5s along with my Nokia Lumia 920 ... yes, I have three phones ... I'm trying to learn development across all three in my spare time.

    I don't know enough yet to comment on the TECHNICAL differences between the phone hardware or OS's.  I only know my personal preferences from a consumer perspective at this point.  I know there are others who are much more well versed in the technical areas than I am.

    My impressions of the Samsung Galaxy S4 ... 

    (1) It's a tweakers dream ... you can change just about everything about the phone and which apps handle phone events, even the start screen, tapping on the button, etc.

    (2) It's too much power for the average person.  It's as if they shipped R2-D2 in a kit and let you assemble and change out his functionality to your liking.  However, unless you're prepared to tinker with your phone for days it will be maddening.  At some point I had to have a friend walk me through how to get the most out of the phone.

    (3) Worst, it serves three masters.  It has multiple personality disorder.  Google, AT&T and Samsung are all vying for control of the device.  My contacts are owned by AT&T and Google can't see them ... not sure how that happened, but makes sending texts absolutely frustrating.  You can't uninstall the apps from any of those companies.  I complained to a friend at Samsung and he agreed with me.  He also said that when his wife got a new phone he had to set it up for her and she didn't like it.

    For me, simplicity is the key.  I just want my phone to work, I don't need to tweak everything if it's obvious from the start.

  • User profile image
    Dan

    Thanks, that was a great overview of xaml.

  • User profile image
    sama20073

    I understand so much new item I don't know it before In xaml but when I show your course I feel something difficult in understand hhh that for reason my English language is some poor but rely is very good explain and easy to understood.

    thank you for this explain Mr. Bob.  

  • User profile image
    varunsinghal

    Sir first of all the entire series is amazing and i would really like to thank all those people who have put in their valuable time and energy in making this series a success.

    Next sir i have three questions:

    1. Why <grid x:Name="ContentPanel"> cant be written as  < grid Name="ContentPanel"> (line 30).

    2. What are phone , shell , x , mc after collen in lines 4-8.

    3. What is the fundamental difference between schemas and namespaces . or are they synonymous, i am a bit confused .

    Thanks in advance Sir

  • User profile image
    Clint

    @varunsinghal:

    1. it can, but needs to be Grid with a capital G
    2. those are namespaces declared at the top, most of the time you won't have to deal with them unless you are doing more advanced stuff like referencing items in different assemblies
    3. schema declares what something should look like, a namespace is where something lives / scope of it.  https://msdn.microsoft.com/en-us/library/z2kcy19k.aspx for namespace.  http://en.wikipedia.org/wiki/XML_schema for schema
  • User profile image
    JasminMankad

    Hello Sir,

    I am from India and a huge fan after C# series.

    I am just wondering about a thing. In this lesson you have told about how to declare a Button member in C# page (MainPage.xaml.cs). So my question is if an app has buttons declared using C# code then if it has better performance than ones with XAML or not, as XAML integrally does type conversions. 

  • User profile image
    Clint
    @JasminMankad: no. I don't recommend pre optimize as well. Optimize when you need to.
  • User profile image
    Hieu

    Hi Bob, why do i creat new button by C#, the preview not change, but when run in emulator, it run correctly.

    // Sorry about my English Big Smile

  • User profile image
    Duncanma

    @Hieu:The preview is just showing you what the XAML will look like, so if you create a button (or another UI element) via code (C#) then that won't show up until the code runs.

  • User profile image
    Hieu

    @Duncanma:Yep, Thanks u Big Smile

  • User profile image
    ravikrana

    Hi Bob . How can i add media element such as image instead of Red button such as i did it using XAML . Here is my code

    <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
    <Button Name="playaudiobutton"
    Height="200" Width="200" HorizontalAlignment="Left" VerticalAlignment="Top" Background="Purple" Click="playaudiobutton_Click_2" >
    <Button.Template>
    <ControlTemplate>
    <Image Source="/Assets/AnimalsPic/quack.png" ></Image>
    </ControlTemplate>
    </Button.Template>
    Quack</Button>
    <MediaElement x:Name="QuackMediaElement"
    Source="/Assets/Audio/Animals/Duck.wav"
    Volume="1"
    AutoPlay="False"
    />

    </Grid>

  • User profile image
    BobTabor

    @ravikrana: I'm not sure what you're asking ... it looks like you've already done what you're asking to do?  Please clarify.

  • User profile image
    mpestana

    Hi guys.
    To change the position for the "Meow" button in C# we could just edit the "mybutton.horizontalallignment" to the right instead writing the Margin specifications number in a diferente line, am i correct? I mean, less code, less work :D

    Many Thanks Bob. Love these series.
    Marco 

  • User profile image
    isamubr

    Hello. First congratulation for the great videos. There is a typo in the writen part.

    In the part 4, the namespace is PetSounds and not SoundBoard.

    The text wrong is <phone:PhoneApplicationPage
    x:Class="SoundBoard.MainPage"
    ...

  • User profile image
    krunal

    Hey BOB,

    Grt Job & thanks a Lot.....

  • User profile image
    Ronald Munodawafa

    Thank you so much for these episodes on Channel 9. They are really useful and I never thought I would actually reach out to learn XAML. I find XAML easier than Drag and Drop development. I feel I can actually write all my code away from my computer in text files and then simply import them into Visual Studio. Windows Phone development is pretty much a simplified procedure - much better and faster than development on other platforms - thanks to you guys. My goal is to push app development on Windows Phone to its limit in terms of aesthetic, efficiency and usefulness. When you chose .wav files for your assets I assumed you would have to use a library to manipulate lossy compression formats like MPEG-4 and Windows Media. But I was wrong. I commend the guys at Microsoft. Great job!

  • User profile image
    shostakovich

    thax for Absolute Beginners..:D

  • User profile image
    Adurability

    Thanks Bob Tabor, Am new on this platform and already enjoying your series... 

  • User profile image
    Adurability

    @Bob Will I need to download window 8 emulator separately???? 

  • User profile image
    cipher2079

    Great Job as Always..Thank you.

  • User profile image
    Qiuhaibo

    Great tutorial!!!Now I have a question raised :When I use the Name or x: Name?

  • User profile image
    cipher2079

    Part 4 was fun. I think you did a great job speaking in Spanish though i cant lie it was kinda funny but overall fun and lots of much need information about XAML...Thank you!! 

  • User profile image
    Jesus Garcia

    Hi Bob, When I write this line of code:
    myButton.Background = new SolidColorBrush(Colors.Red);
    from Solid to Colors. this appears underlined by a red line.
    How can I add this element?

    THanks for your help

  • User profile image
    nisarg

    cant find solidcolorbrush attribute..

  • User profile image
    Nisarg

    When I write this line of code:
    myButton.Background = new SolidColorBrush(Colors.Red);
    from Solid to Colors. this appears underlined by a red line.
    How can I add this element?

  • User profile image
    Andrea

    Do you know if in windows phone 8.0 or 8.1 is it possible to read contact groups from an app? I need to write an app to send sms to group with more than 25 users.
    In windows phone 8 groups have limit of 25 users. You can bypass those limit from outlook, but windows phone in those groups remove the "send sms" button..
    Thanks,
    Andrea

  • User profile image
    ahmed

    my virtualization technology is disabled
    i have an optiplex 960 case
    and i have a bios version A03
    how could i fix this problem
    thanks in advance

  • User profile image
    Simon

    Hi, How can I reverse the option where to choose whether to create a Windows Phone App 8.0 or 8.1, Please?

Add Your 2 Cents