ContentControl与ContentPresenter区别?

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了ContentControl与ContentPresenter区别?相关的知识,希望对你有一定的参考价值。

 <TextBlock HorizontalAlignment="Left" Text="{Binding HwContent, Converter={StaticResource TextSerialize}}" VerticalAlignment="Top" Margin="76,26,160,0" TextTrimming="CharacterEllipsis" Grid.Column="0" Height="Auto" FontSize="14" LineHeight="24" Cursor="Hand" TextWrapping="NoWrap" Foreground="{DynamicResource Foreground_Gray_level2}">
                        <TextBlock.ToolTip >
                            <ContentControl   Content="{Binding HwContent}" >
                                <ContentControl.ContentTemplate>
                                    <DataTemplate>
                                        <Border MaxWidth="600" MinHeight="16" MaxHeight="320" Padding="5,5,5,5">
                                            <TextBlock TextWrapping="Wrap" TextTrimming="CharacterEllipsis" Text="{Binding Mode=OneTime}"/>
                                        </Border>
                                    </DataTemplate>
                                </ContentControl.ContentTemplate>
                            </ContentControl>
                        </TextBlock.ToolTip>
                    </TextBlock>

ContentPresenter显示不出来,但是ContentControl  能显示出来

 

以上是关于ContentControl与ContentPresenter区别?的主要内容,如果未能解决你的问题,请参考以下文章

ContentControl 不显示内容

Margin 和 Padding 是不是由 ContentControl 实现?

ContentControl 未与 TextBlock 中的文本对齐

WPF - 将 ContentControl 添加到自定义画布

背水一战 Windows 10 (77) - 控件(控件基类): ContentControl, UserControl, Page

在 Avalonia 类库中的何处加载 ContentControl 样式?