How to make userControl resize (height only) depends on textbox actual height?

NoobCube

Member
Joined
Mar 2, 2014
Messages
12
Programming Experience
Beginner
Hello,
I have userControl and textbox in it.
I want to make userControl resize itself depends on textbox actual height.
my textbox height is changing when I start new line.
but userControl size can only grow.
I used this binding in userControl:
C#:
Height="{Binding ActualHeight, ElementName=txtTask, Mode=OneWay}


I tried to bind userControl height to textBox.actualHeight and I have set height to auto etc.
and every other possible option.


now when I load my userControl its height is twice bigger than textBox and userControl resize itself only on textBox growth.
:indecisiveness:


How to do it right? what causing this problem?
I want to use bindings.


Thanks.
 
Last edited:

NoobCube

Member
Joined
Mar 2, 2014
Messages
12
Programming Experience
Beginner
Solved this problem by using Label with AccessText:
C#:
<Label x:Name="Task" FontWeight="Bold" FontSize="14" Padding="0" Margin="2,0" ScrollViewer.VerticalScrollBarVisibility="Disabled" VerticalAlignment="Top">
            <AccessText x:Name="TaskText" TextWrapping="WrapWithOverflow" ScrollViewer.VerticalScrollBarVisibility="Disabled" MinWidth="200" MinHeight="20" FontSize="12" FontWeight="Normal" Margin="3,4" VerticalAlignment="Top" Text="Content here"/>
</Label>

userControl bind:
C#:
Height="{Binding ActualHeight, ElementName=TaskText, Mode=OneWay}"

when user rightclick on userControl it shows TextBox and copy text from TaskText...
 
Top Bottom