Windows Vista Forums
Vista Forums Home Join Vista Forums Windows 7 Forum Vista Tutorials Tags
Welcome to Windows Vista Forums. Our forum is dedicated to helping you find solutions with any problems, errors or issues you are experiencing with Windows Vista. The Vista forum also covers news and updates and has an extensive Windows Vista tutorial section that covers a wide range of tips and tricks.

Go Back   Vista Forums > Misc Newsgroups > Avalon

Vista - How to get Size of parent in a template

 
 
Old 06-27-2006   #1 (permalink)
Sam Jost


 
 

How to get Size of parent in a template

I've created my own Template for a TextBox so I can draw a custom
border.
The initial size of the TextBox I can bind to without problems using
something like

<PathFigure StartPoint="{Binding ElementName=Label, Path=RenderSize,
Converter={StaticResource sizeToPoint}}">

Only problem is: when the size of the TextBox does change for whatever
reason, my custom border's size stays the same. The border does not
reflect the changes of the size of the TextBox.

My guess is I need to get the size in a different way, but I don't know
where to get it. And I can't use Rectangle, or Border to just fill the
border since these two can't draw what I need.

Anyone got an idea how to bind to the size of a control so my template
does grow and shrink with it?

Thanks,
Sam


My System SpecsSystem Spec
Old 06-27-2006   #2 (permalink)
Suresh


 
 

Re: How to get Size of parent in a template

Hey Sam,

Try binding to ActualHeight and ActualWidth of the TextBox instead
of RenderSize.


Sam Jost wrote:
> I've created my own Template for a TextBox so I can draw a custom
> border.
> The initial size of the TextBox I can bind to without problems using
> something like
>
> <PathFigure StartPoint="{Binding ElementName=Label, Path=RenderSize,
> Converter={StaticResource sizeToPoint}}">
>
> Only problem is: when the size of the TextBox does change for whatever
> reason, my custom border's size stays the same. The border does not
> reflect the changes of the size of the TextBox.
>
> My guess is I need to get the size in a different way, but I don't know
> where to get it. And I can't use Rectangle, or Border to just fill the
> border since these two can't draw what I need.
>
> Anyone got an idea how to bind to the size of a control so my template
> does grow and shrink with it?
>
> Thanks,
> Sam


My System SpecsSystem Spec
Old 06-28-2006   #3 (permalink)
Sam Jost


 
 

Re: How to get Size of parent in a template

Suresh,

These two look great! I could bind to ActualWidth or ActualHeight and
all sizes get updated just like I'd like them to.

But how do I bind to both of them at once? Writing a converter is easy,
but in the binding I have to decide for ActualHeight or ActualWidth, I
can't have them both at once

I tried to bind them like

<LineSegment>
<LineSegment.Point>
<Point
X="{Binding RelativeSource={RelativeSource TemplatedParent},
Path=ActualWidth"}"
Y="{Binding RelativeSource={RelativeSource TemplatedParent},
Path=ActualHeight"}"
</LineSegment.Point>
</LineSegment>

but I only get an error message saying I cant attack a binding to the
double 'X'

How do I bind to both at once??

Thanks a lot,
Sam


Suresh schrieb:

> Hey Sam,
>
> Try binding to ActualHeight and ActualWidth of the TextBox instead
> of RenderSize.
>
>
> Sam Jost wrote:
> > I've created my own Template for a TextBox so I can draw a custom
> > border.
> > The initial size of the TextBox I can bind to without problems using
> > something like
> >
> > <PathFigure StartPoint="{Binding ElementName=Label, Path=RenderSize,
> > Converter={StaticResource sizeToPoint}}">
> >
> > Only problem is: when the size of the TextBox does change for whatever
> > reason, my custom border's size stays the same. The border does not
> > reflect the changes of the size of the TextBox.
> >
> > My guess is I need to get the size in a different way, but I don't know
> > where to get it. And I can't use Rectangle, or Border to just fill the
> > border since these two can't draw what I need.
> >
> > Anyone got an idea how to bind to the size of a control so my template
> > does grow and shrink with it?
> >
> > Thanks,
> > Sam


My System SpecsSystem Spec
 

Thread Tools


Similar Threads
Thread Forum
Parent Process ID PowerShell
Collections Help when in a parent class .NET General
Fetch NTDS directoryEntry parent? PowerShell
Get parent directory PowerShell


Vista Forums 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 Ltd

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