Windows Vista Forums
Vista Forums Home Join Vista Forums Donate Vista Tutorials Tags

Welcome to Vista Forums we are your forum to discuss Windows Vista x64 and x86 systems. Whether you need help or just want to post an idea you have on Vista, this is the forum for you.
Register at Vista forums...the world biggest Windows Vista resource Join Vista Forums Now

Go Back   Vista Forums > Microsoft Technical Newsgroups > Avalon

How to reference another element in the same XAML file?

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 09-27-2006   #1 (permalink)
TyraelTong
Guest


 

How to reference another element in the same XAML file?

Say, MyControl is a custom control which have a property of type
Button. How could I set this property to myButton? I think is maybe
like this:

<Button name="myButton">ClickMe</Button>
<MyControl buttonProp="myButton"/>


My System SpecsSystem Spec
Old 09-27-2006   #2 (permalink)
Douglas Stockwell
Guest


 

Re: How to reference another element in the same XAML file?

If buttonProp is a dependency proprty you can use Data Binding:

<Button Name="myButton">ClickMe</Button>
<MyControl buttonProp="{Binding ElementName=myButton}"/>

If its an ordinary CLR property, I think even in this case you'll have to do
it from code-behind.

<Button Name="myButton">ClickMe</Button>
<MyControl Name="myControl" />

myControl.buttonProp = myButton;

- Doug


"TyraelTong" <TyraelTong@gmail.com> wrote in message
news:1159361103.159994.47290@h48g2000cwc.googlegroups.com...
> Say, MyControl is a custom control which have a property of type
> Button. How could I set this property to myButton? I think is maybe
> like this:
>
> <Button name="myButton">ClickMe</Button>
> <MyControl buttonProp="myButton"/>
>


My System SpecsSystem Spec
Old 09-27-2006   #3 (permalink)
Douglas Stockwell
Guest


 

Re: How to reference another element in the same XAML file?

If buttonProp is a dependency proprty you can use Data Binding:

<Button Name="myButton">ClickMe</Button>
<MyControl buttonProp="{Binding ElementName=myButton}"/>

If its an ordinary CLR property, I think even in this case you'll have to do
it from code-behind.

<Button Name="myButton">ClickMe</Button>
<MyControl Name="myControl" />

myControl.buttonProp = myButton;

- Doug


"TyraelTong" <TyraelTong@gmail.com> wrote in message
news:1159361103.159994.47290@h48g2000cwc.googlegroups.com...
> Say, MyControl is a custom control which have a property of type
> Button. How could I set this property to myButton? I think is maybe
> like this:
>
> <Button name="myButton">ClickMe</Button>
> <MyControl buttonProp="myButton"/>
>


My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Trouble with resize ratio of XAML element Mike D Avalon 0 02-18-2008 03:03 AM
Can you reference a XAML Resource from an External Assembly? wackyphill@yahoo.com Avalon 3 02-05-2007 06:52 AM
Best way to reference ConfigurationManager.AppSettings in XAML Keith Patrick Avalon 0 12-19-2006 02:19 PM
Custom Window as a XAML root element! deepforest Avalon 2 11-23-2006 10:16 AM
Reference a xaml window from a WinFX Custom Control Library ? Peter Fitzgibbons Avalon 3 02-24-2006 04:11 PM


Update your Vista Drivers Update Your Vista Drivers Now!!

Vistax64.com is an independent web site and has not been authorized,
sponsored, or otherwise approved by Microsoft Corporation.
"Windows Vista", the Start Orb, and related materials are trademarks of Microsoft Corp.
© Designer Media 2005-2008
Page generated in 0.23107 seconds with 10 queries