If you are not explicitly setting the Width/Height
, you will have to change your template bindings to ActualWidth/ActualHeight
:
<VisualBrush.Visual>
<Rectangle StrokeDashArray="8, 2" Stroke="{TemplateBinding BorderBrush}"
StrokeThickness="2"
Width="{TemplateBinding ActualWidth}"
Height="{TemplateBinding ActualHeight}"/>
</VisualBrush.Visual>
Layout:(if I understand your question correctly)
<Grid>
<ContentControl >
<TextBox BorderBrush="Red" Background="Blue" Style="{StaticResource ControlFrame}" />
</ContentControl>
</Grid>
ActualWidth/ActualHeight
will return the rendered size of the control, Width/Height
will returm NaN if its not explicity set elsewhere.