Quantcast
Channel: Windows Presentation Foundation (WPF) forum
Viewing all articles
Browse latest Browse all 18858

TemplateBinding

$
0
0

Why is the following working only for the Rectangle, not the TextBox ?

    <Window.Resources>
        <ControlTemplate x:Key="MyProgressBarTemplate" TargetType="ProgressBar">
            <StackPanel Orientation="Vertical">
                <Rectangle
   Width="{TemplateBinding Property=Value}"
   Stroke="Red"
   StrokeThickness="3"
   Height="25"/>
                <TextBox
   Text="{TemplateBinding Property=Value}" />
            </StackPanel>
        </ControlTemplate>
    </Window.Resources>

If I change the TextBox attributes to:

DataContext="{TemplateBinding Property=Value}" Text="{Binding Mode=OneWay}"

then it is working ok, I just wonder why I must set the DataContext for the TextBox and not for the Rectangle ?


Viewing all articles
Browse latest Browse all 18858

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>