![]() |
![]() | ![]() | ![]() | ![]() | ![]() | ![]() | ![]() |
| 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. |
| |||||||
| |
| | #1 (permalink) |
| | 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 Specs![]() |
| | #2 (permalink) |
| | 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 Specs![]() |
| | #3 (permalink) |
| | 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 Specs![]() |
| 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 | |||