Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Register | FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
BOOK: Beginning Windows Phone 7 Application Development: Building Windows Phone Applications Using S
This is the forum to discuss the Wrox book Beginning Windows Phone 7 Application Development: Building Windows Phone Applications Using Silverlight and XNA by Nick Lecrenski, Karli Watson, Robert Fonseca-Ensor; ISBN: 978-0-470-91233-1
Welcome to the p2p.wrox.com Forums.

You are currently viewing the BOOK: Beginning Windows Phone 7 Application Development: Building Windows Phone Applications Using S section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developersí questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
 
 
Thread Tools Display Modes
  #1 (permalink)  
Old July 29th, 2011, 10:14 PM
Registered User
 
Join Date: Jul 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default Code Examples - Chapter 4 - Using Control Templates

Is anyone besides me having a problem with this example?
I have loaded the code from the download page and it's not working.
The error code indicates there is a missing static resource definition for the CustomControlButton, but I can't find anywhere how to define it.
Thanks for any help.
  #2 (permalink)  
Old August 1st, 2011, 08:56 PM
Wrox Author
 
Join Date: May 2009
Posts: 13
Thanks: 0
Thanked 2 Times in 2 Posts
Default Code

Is this for the ControlTemplate solution? If so the StaticResource it is referring to is located in App.xaml. I just downloaded the code from the site and it appears to be working fine.

Can you give me more information about your setup? Visual Studio version, OS, etc...?

Thanks
  #3 (permalink)  
Old August 2nd, 2011, 12:00 AM
Registered User
 
Join Date: Jul 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Quote:
Originally Posted by nlecren View Post
Is this for the ControlTemplate solution? If so the StaticResource it is referring to is located in App.xaml. I just downloaded the code from the site and it appears to be working fine.

Can you give me more information about your setup? Visual Studio version, OS, etc...?

Thanks
Yes, this is for the ControlTemplate Solution.

I downloaded the code again for this example and created a new project, and copied the code directly from the download into Visual Studio 2010 Professional for the files listed in the book for this "try it out". The files I copied/pasted are:
MainPage.xaml
App.xaml
MainPage.xaml.cs

I still have this error:
The name 'InitializeComponent' does not exist in the current context
the line number indicated for this error is "49", the column number indicated is 13, the file indicated is app.xaml.cs
I copied/pasted the code from the download so I wouldn't have any issues with entering something incorrectly.

I also had tried this example with the Visual Studio Express 2010 for Windows Phone environment and got the same error.

Here is the info on the setup I am using:
Microsoft Visual Studio 2010
Version 10.0.30319.1 RTMRel
Microsoft .NET Framework
Version 4.0.30319 RTMRel

Installed Version: Professional

Microsoft Office Developer Tools 01018-532-2002102-70346
Microsoft Office Developer Tools

Microsoft Visual Basic 2010 01018-532-2002102-70346
Microsoft Visual Basic 2010

Microsoft Visual C# 2010 01018-532-2002102-70346
Microsoft Visual C# 2010

Microsoft Visual C++ 2010 01018-532-2002102-70346
Microsoft Visual C++ 2010

Microsoft Visual F# 2010 01018-532-2002102-70346
Microsoft Visual F# 2010

Microsoft Visual Studio 2010 Team Explorer 01018-532-2002102-70346
Microsoft Visual Studio 2010 Team Explorer

Microsoft Visual Web Developer 2010 01018-532-2002102-70346
Microsoft Visual Web Developer 2010

Microsoft Windows Phone Developer Tools - ENU 01018-532-2002102-70346
Microsoft Windows Phone Developer Tools - ENU

Crystal Reports Templates for Microsoft Visual Studio 2010
Crystal Reports Templates for Microsoft Visual Studio 2010

Microsoft Visual Studio 2010 SharePoint Developer Tools 10.0.30319
Microsoft Visual Studio 2010 SharePoint Developer Tools

Microsoft XNA Game Studio 4.0
Microsoft XNA Game Studio 4.0
Build 4.0.20823.0
---

It could be that you have a resource defined on your machine that I need to also define, but I haven't a clue what or where.

Thanks,
Frances

Last edited by frances@uswnet.com; August 2nd, 2011 at 12:02 AM. Reason: corrected spelling
  #4 (permalink)  
Old August 2nd, 2011, 12:21 AM
Wrox Author
 
Join Date: May 2009
Posts: 13
Thanks: 0
Thanked 2 Times in 2 Posts
Default Project

Ok, looks like you are almost there. If you are trying to copy files from the download you will need to Add an Images directory to the project and copy the wrox.png file to that directory.

Then make sure you copy App.xaml, App.xaml.cs, MainPage.xaml, and MainPage.xaml.cs

Looking at this error it seems like you might be missing the App.xaml.cs file in your project.
  #5 (permalink)  
Old August 2nd, 2011, 08:48 PM
Registered User
 
Join Date: Jul 2011
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Default

I added an Images directory to the project and copied the wrox.png file to that directory.

I then copied these files: App.xaml, App.xaml.cs, MainPage.xaml, MainPage.xaml.cs

I still have the error.

I extracted the files for the ControlTemplate example, opened the .sln file as a new project and it worked.

I still don't understand what the problem is.
  #6 (permalink)  
Old May 1st, 2012, 04:17 AM
Registered User
Points: 15, Level: 1
Points: 15, Level: 1 Points: 15, Level: 1 Points: 15, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Hi,
I've come across a similar issue, aswell as someone else who has posted here.
they only difference I can see between my code and the downloaded code is
The books example is AppPlatformVersion="7.0"
and mine is AppPlatformVersion="7.1"

Was there some type of change between the two versions?
  #7 (permalink)  
Old May 2nd, 2012, 05:51 AM
Registered User
Points: 15, Level: 1
Points: 15, Level: 1 Points: 15, Level: 1 Points: 15, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2012
Posts: 5
Thanks: 0
Thanked 0 Times in 0 Posts
Smile Fixed It!

Ok I discovered the fix.

in the app.xaml file you need to include the TargetType="Button" in the <ControlTemplate> element. Like so

Code:
<Application.Resources>
        <Style x:Key="CustomButtonStyle" TargetType="Button">
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Button">


To the authors you may want to amend this in any later editions.

These are the pages at which I have picked up this error/typo/missing property. (so far)

Pg 144 Listing 4-5
It is included on pg 177
page 121 Listing 4-7 (Also on this page please include the x:Name properties of the image and Textblock elements in the control Template, took me a while to figure that out that they slipped in with the next part of the example because the emphasis is on adding the visual state groups, or go thru and bold any changes in these examples like you seem to do from chapter 6 onwards)
page 123 under step 6.

Unrelated feedback so far.. (only up to chapter 4)
pg 125 step 12:
please mention to not only give the stackPanel a darkgrey Background but again include the x:Name="MainPanel" attribute

Happy re-editing!

P.S I tried to submit via the Errata form on the book info page.. it took me to a submit question page.. and you wanted my address and phone number? no thanks. Maybe the link is wrong or may be the errata form is the "question" page, but im not going to give you all my personal info just to help you with some feedback..seems a bit much. Sorry to all the people who spend time trying to fix these issues hopefully they will find their way here promptly if they purchase any later editions. Feel free to email / message me for further info..

If I come across any more things I think might need to be updated in any later editions i'll attempt to post them in this forum. Maybe one of the authors will read this and follow up.
Peace out!

Last edited by mcbain; May 2nd, 2012 at 06:21 AM.
 


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
examples of dynamic user control vegeta4ss BOOK: Beginning ASP.NET 2.0 BOOK VB ISBN: 978-0-7645-8850-1; C# ISBN: 978-0-470-04258-8 1 June 4th, 2007 03:26 PM
Chapter 11 Code Examples ablinco BOOK: Professional VB 2005 ISBN: 0-7645-7536-8 0 October 9th, 2006 03:56 AM



All times are GMT -4. The time now is 07:30 AM.


Powered by vBulletin®
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.