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 April 22nd, 2012, 01:54 PM
Registered User
Points: 5, Level: 1
Points: 5, Level: 1 Points: 5, Level: 1 Points: 5, Level: 1
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Apr 2012
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default Control Template

Help me.
When i run this code:
PHP Code:
<Style x:Key="ImageButton" TargetType="Button">
            <
Setter Property="Template">
                <
Setter.Value>
                    <
ControlTemplate>
                        <
StackPanel Height="{TemplateBinding Height}" Width="{TemplateBinding Width}">
                            <
Image Height="100" Width="100" Source="wrox.png" />
                            <
TextBlock Text="{TemplateBinding Content}" />
                        </
StackPanel>
                    </
ControlTemplate>
                </
Setter.Value>
            </
Setter>
        </
Style
is this error appear
PHP Code:
private void Application_UnhandledException(object senderApplicationUnhandledExceptionEventArgs e)
        {
            if (
System.Diagnostics.Debugger.IsAttached)
            {
                
// An unhandled exception has occurred; break into the debugger
                
System.Diagnostics.Debugger.Break();
            }
        } 
And when i remove this line: <TextBlock Text="{TemplateBinding Content}" />
program can run
  #2 (permalink)  
Old April 30th, 2012, 06:35 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 there,
I also get the same error.. I also get a related error when you do the next tutorial regarding the Control Templates and applying custome Visual States.

Within the
PHP Code:
                        <Grid>
                            <
VisualStateManager.VisualStateGroups>
                                <
VisualStateGroup x:Name="CommonButtonStates">
                                    <
VisualState x:Name="Normal" />
                                    <
VisualState x:Name="Pressed" >
                                        <
Storyboard>
                                            <
ObjectAnimationUsingKeyFrames Duration="0" 
Storyboard.TargetName="MainBorder" Storyboard.TargetProperty="BorderBrush">
                                                <
DiscreteObjectKeyFrame KeyTime="0" Value="Red" />
                                            </
ObjectAnimationUsingKeyFrames>
                                        </
Storyboard>
                                    </
VisualState>
                                    <
VisualState x:Name="Disabled" />
                                </
VisualStateGroup>
                            </
VisualStateManager.VisualStateGroups>
                            <
Border Width="{TemplateBinding Width}" Height="{TemplateBinding Height}" 
BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}">
                                <
StackPanel>
                                    <
Image Source="Images\wrox.png" Width="200" Height="300" />
                                    <
TextBlock  TextAlignment="Center" />
                                </
StackPanel>
                            </
Border>
                        </
Grid>
                    </
ControlTemplate
when you add a button and use this template there is an exception thrown when you click the button

+ _exception {"Cannot resolve TargetName MainBorder."} System.Exception {System.InvalidOperationException}


If anyone else knows how / why this is occurring it would be great to know so I can continue with the exercises. Also maybe needed for future revisions of the book..

to the OP I am also asking via stack overflow so if I get an answer I'll post a link here, could you do the same as well if you figure it out?

Thanks

Last edited by mcbain; April 30th, 2012 at 06:53 AM.
  #3 (permalink)  
Old April 30th, 2012, 06:52 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

here is part of the answer
http://stackoverflow.com/questions/1...nown-exception
  #4 (permalink)  
Old May 2nd, 2012, 05:53 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 Fixed It!

Found out the error.. Check out
Code Examples - Chapter 4 - Using Control Templates
 


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
Image Button as Template Field in GridView control vbmazza ASP.NET 2.0 Professional 10 May 27th, 2007 10:03 AM
pbm to find control ref in datagrid template forums.praveen VS.NET 2002/2003 0 March 13th, 2007 11:54 PM
Dynamic Template Repeater Find Control zac ASP.NET 1.0 and 1.1 Professional 0 October 9th, 2003 10:30 AM



All times are GMT -4. The time now is 10:09 AM.


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