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

Binding properties of two elements on a canvas

Update your Vista Drivers Update Your Drivers Now!!
Closed Thread
 
Thread Tools Display Modes
Old 06-14-2006   #1 (permalink)
Illumineo
Guest


 

Binding properties of two elements on a canvas

A canvas has two rectangles, one of which can be moved by means of a
slider. Is it possible to let the second follow the first by binding to
the 'Canvas.Left' of the rectangle?

The line
<Binding ElementName="rec" Path="Canvas.Left">
seems to be accepted in XAMLPad but does not produce the expected
result.




<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
>


<Canvas>
<StackPanel Orientation="Vertical" >

<StackPanel Orientation="Horizontal" >
<Slider Margin="5,5,5,5" Name="slider2"
DockPanel.Dock="Top" Maximum="1000"
Minimum="10" />
<Label Content="{Binding ElementName=slider2,
Path=Value}"></Label>
</StackPanel>
</StackPanel>
<Rectangle
Width="50"
Height="50"
Fill="yellow"
Canvas.Left="{Binding ElementName=slider2, Path=Value}"
Canvas.Bottom="325"
Name="rec"
/>

<Rectangle
Width="50"
Height="50"
Fill="Red"
Canvas.Top="120"
>

<Canvas.Left>
<Binding ElementName="rec" Path="Canvas.Left"> <!--- this is allowed
but does not work... */ -->

</Binding>
</Canvas.Left>
</Rectangle>
</Canvas>
</Page>


[Thanks]


My System SpecsSystem Spec
Old 06-14-2006   #2 (permalink)
viliescu
Guest


 

RE: Binding properties of two elements on a canvas

Instead of Path="Canvas.Left" use Path="(Canvas.Left)"
--
Valentin Iliescu [MVP - Client Application Development]


"Illumineo" wrote:

> A canvas has two rectangles, one of which can be moved by means of a
> slider. Is it possible to let the second follow the first by binding to
> the 'Canvas.Left' of the rectangle?
>
> The line
> <Binding ElementName="rec" Path="Canvas.Left">
> seems to be accepted in XAMLPad but does not produce the expected
> result.
>
>
>
>
> <Page
> xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
> xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
> >

>
> <Canvas>
> <StackPanel Orientation="Vertical" >
>
> <StackPanel Orientation="Horizontal" >
> <Slider Margin="5,5,5,5" Name="slider2"
> DockPanel.Dock="Top" Maximum="1000"
> Minimum="10" />
> <Label Content="{Binding ElementName=slider2,
> Path=Value}"></Label>
> </StackPanel>
> </StackPanel>
> <Rectangle
> Width="50"
> Height="50"
> Fill="yellow"
> Canvas.Left="{Binding ElementName=slider2, Path=Value}"
> Canvas.Bottom="325"
> Name="rec"
> />
>
> <Rectangle
> Width="50"
> Height="50"
> Fill="Red"
> Canvas.Top="120"
> >

> <Canvas.Left>
> <Binding ElementName="rec" Path="Canvas.Left"> <!--- this is allowed
> but does not work... */ -->
>
> </Binding>
> </Canvas.Left>
> </Rectangle>
> </Canvas>
> </Page>
>
>
> [Thanks]
>
>

My System SpecsSystem Spec
Closed Thread

Thread Tools
Display Modes



Similar Threads
Thread Thread Starter Forum Replies Last Post
Can't delete elements in folder Recent elements Gudmund Liebach Nielsen Vista General 1 05-05-2008 07:17 PM
Binding to properties of a user control Dave Avalon 1 04-10-2008 08:29 AM
Binding inside binding question Yoavo Avalon 0 12-03-2007 08:24 AM
Binding Question (Binding in General) Jason Avalon 2 05-09-2007 04:41 AM
Support for Adobe photoshop elements 5 or premier elements 3 on Vista 64 bits Sébastien DELAYRE Vista General 5 03-26-2007 09:57 AM


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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51