I'm currently creating my own textbox control, which, in addition to text, displays a small icon. This icon is being held in resources as a ViewBox
with some Path
s.
Currently, the template looks like the following (the relevant part):
<Border x:Name="Border" BorderThickness="1"
BorderBrush="{TemplateBinding BorderBrush}"
Background="{TemplateBinding Background}">
<DockPanel>
<ContentPresenter Content="{TemplateBinding ImageContent}"
DockPanel.Dock="Left"
Margin="2"
Width="{Binding ElementName=PART_ContentHost, Path=Height}"
Height="{Binding ElementName=PART_ContentHost, Path=Height}" />
<ScrollViewer x:Name="PART_ContentHost" Margin="2"/>
</DockPanel>
</Border>
The problem is, that despite fact, that I set the image's width and height to the height of the main part of the textbox, it always fill as much free space as it can, resulting in huge image covering the whole screen.
I want this element to size itself in regard to the PART_ContentHost
. How can I achieve it?
Solved. The solution is to use
PART_ContentHost
'sDesiredHeight
instead ofHeight
. Welcome to the WPF layout system...