【问题标题】:How to use content template for ComboBox content presenter?如何为 ComboBox 内容演示者使用内容模板?
【发布时间】:2012-10-17 17:06:42
【问题描述】:

在下面的文件中,有一个 COmboBox 的示例 - 控件模板。 http://msdn.microsoft.com/en-us/library/ms752094(v=vs.85).aspx

我尝试使用以下 XAML 为内容演示者添加内容模板。但它将值“1”显示为“[1,1]”。

如何将 selectedValue 绑定到 textblock 的文本?

<ContentPresenter x:Name="ContentSite" Visibility="Visible" IsHitTestVisible="False" Content="{TemplateBinding SelectionBoxItem}"
                                ContentTemplateSelector="{TemplateBinding ItemTemplateSelector}"
                                VerticalAlignment="Center" HorizontalAlignment="Stretch">
                                <ContentPresenter.ContentTemplate>
                                    <DataTemplate>
                                        <TextBlock Background="#FFFF99" Text="{Binding }" />
                                    </DataTemplate>
                                </ContentPresenter.ContentTemplate>
                            </ContentPresenter>

【问题讨论】:

  • 请粘贴 XAML,显示您如何使用它。

标签: wpf combobox contentpresenter control-template


【解决方案1】:

我已经对此进行了修复。在内容演示者周围有一个 GRID...并在控件模板的触发器中设置该 GRID 的背景颜色。

【讨论】:

    猜你喜欢
    • 2012-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2016-03-05
    • 2015-11-09
    • 1970-01-01
    • 2017-11-29
    相关资源
    最近更新 更多