0
所以我正在为我的WPF应用程序制作自定义窗口模板。我遇到的麻烦是我无法访问模板内的窗口标题属性。TemplateBinding自定义窗口模板中的标题WPF
我尝试这样做:
<TextBlock Text="{TemplateBinding Title}" />
而这一点:我读过
<TextBlock Text="{Binding RelativeSource={RelativeSource TemplatedParent}, Path=Title}" />
一切都表明,要么这两个应该都是正常,但文本从未设置。
有什么建议吗?
编辑:呈现整个风格XAML
<Style x:Key="RegularWindow" TargetType="{x:Type Window}">
<Setter Property="Foreground" Value="{StaticResource {x:Static SystemColors.WindowTextBrushKey}}"/>
<Setter Property="Background" Value="Transparent"/>
<Setter Property="AllowsTransparency" Value="True"/>
<Setter Property="WindowStyle" Value="None"/>
<Setter Property="SizeToContent" Value="WidthAndHeight"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type Window}">
<Border BorderBrush="{TemplateBinding BorderBrush}" CornerRadius="10" Background="{TemplateBinding Background}">
<Grid>
<Grid.RowDefinitions>
<RowDefinition/>
<RowDefinition/>
</Grid.RowDefinitions>
<TextBlock Text="{TemplateBinding Title}" FontWeight="Bold" Grid.Row="0" />
<AdornerDecorator Grid.Row="1">
<ContentPresenter/>
</AdornerDecorator>
</Grid>
</Border>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>
你能分享xaml模板代码吗? – 2010-06-28 03:56:44