Wrox Programmer Forums
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
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
 
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..
 
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
 
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




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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.