为什么有些TemplateBinding值不在设计师显示,但其他人? [与摄制代码] [英] Why are some TemplateBinding values not shown in designer but others are? [with repro code]

查看:157
本文介绍了为什么有些TemplateBinding值不在设计师显示,但其他人? [与摄制代码]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个奇怪的情况:
以下示例代码替换窗口的内容,使用二传手的背景颜色,并提供了两个标签堆栈面板。其中一个背景和一个标题



的事情是,他们在设计时
<标签内容= {TemplateBinding背景}/> 不完美但是$ b $显示背景值b <标签内容={TemplateBinding标题}/> 这是否在运行应用程序时才会出现。
有什么区别吗?



我与周围的TargetType出场(将其设置为主窗口,没有效果)



这是全样本:

 <窗​​口x:类=TBinding.MainWindow的xmlns =htt​​p://schemas.microsoft.com/winfx/2006/xaml/presentation的xmlns:X =htt​​p://schemas.microsoft.com/winfx/2006/xamlHEIGHT =350WIDTH = 525> 
< Window.Style>
<风格的TargetType =窗口>
< setter属性=背景VALUE =草绿/>
< setter属性=标题VALUE =此窗口的标题为/>
< setter属性=模板>
< Setter.Value>
<的ControlTemplate的TargetType =窗口>
< StackPanel的保证金=50背景={TemplateBinding背景}>
<标签内容={TemplateBinding背景}/>
<标签内容={TemplateBinding标题}/>
< / StackPanel的>
< /控件模板>
< /Setter.Value>
< /二传手>
< /样式和GT;
< /Window.Style>
< /窗GT;


解决方案

上找到连接:的 https://connect.microsoft.com/VisualStudio/feedback/details/770067/wpf-设计师 - 不笑



设计师创建窗口类的代理,而不是窗口本身。替代并不能完全反映所有的属性,因此具有有限的功能。



会出现此问题VS2012以及在VS2013。


I've got an odd situation: Following sample code replaces the Content of the window, uses the setter's background color and provides a stack panel with two labels. One for the background and one for the title.

The thing is, that they during design time <Label Content="{TemplateBinding Background}" /> does perfectly show the background value however <Label Content="{TemplateBinding Title}" /> does that only when running the app. What is the difference here?

I've played around with the TargetType (by setting it to MainWindow, no effect)

This is the full sample:

<Window x:Class="TBinding.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Height="350" Width="525">
    <Window.Style>
        <Style TargetType="Window">
            <Setter Property="Background" Value="LawnGreen" />
            <Setter Property="Title" Value="The title of this window" />
            <Setter Property="Template">
                <Setter.Value>
                    <ControlTemplate TargetType="Window">
                        <StackPanel Margin="50" Background="{TemplateBinding Background}">
                                <Label Content="{TemplateBinding Background}" />
                                <Label Content="{TemplateBinding Title}" />
                        </StackPanel>
                        </ControlTemplate>
                    </Setter.Value>
                </Setter>
            </Style>
        </Window.Style>
</Window>

解决方案

Found on connect: https://connect.microsoft.com/VisualStudio/feedback/details/770067/wpf-designer-not-sho

Designer creates a proxy for Window classes and not the Window itself. The substitute does not fully reflect all properties therefore has limited functionality.

This issues occurs in VS2012 as well in VS2013.

这篇关于为什么有些TemplateBinding值不在设计师显示,但其他人? [与摄制代码]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆