惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

Simon Willison's Weblog
Simon Willison's Weblog
P
Privacy International News Feed
www.infosecurity-magazine.com
www.infosecurity-magazine.com
T
Troy Hunt's Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
Attack and Defense Labs
Attack and Defense Labs
S
Secure Thoughts
V2EX - 技术
V2EX - 技术
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
O
OpenAI News
Cloudbric
Cloudbric
Google Online Security Blog
Google Online Security Blog
Schneier on Security
Schneier on Security
cs.CV updates on arXiv.org
cs.CV updates on arXiv.org
Help Net Security
Help Net Security
Cyberwarzone
Cyberwarzone
G
GRAHAM CLULEY
L
Lohrmann on Cybersecurity
Threat Intelligence Blog | Flashpoint
Threat Intelligence Blog | Flashpoint
Spread Privacy
Spread Privacy
NISL@THU
NISL@THU
N
News and Events Feed by Topic
T
Tenable Blog
S
Security @ Cisco Blogs
N
News and Events Feed by Topic
The Hacker News
The Hacker News
C
CXSECURITY Database RSS Feed - CXSecurity.com
宝玉的分享
宝玉的分享
月光博客
月光博客
酷 壳 – CoolShell
酷 壳 – CoolShell
美团技术团队
奇客Solidot–传递最新科技情报
奇客Solidot–传递最新科技情报
Google DeepMind News
Google DeepMind News
钛媒体:引领未来商业与生活新知
钛媒体:引领未来商业与生活新知
T
Tailwind CSS Blog
V
Visual Studio Blog
P
Proofpoint News Feed
Webroot Blog
Webroot Blog
让小产品的独立变现更简单 - ezindie.com
让小产品的独立变现更简单 - ezindie.com
博客园 - 三生石上(FineUI控件)
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org
Jina AI
Jina AI
雷峰网
雷峰网
T
The Blog of Author Tim Ferriss
Hugging Face - Blog
Hugging Face - Blog
腾讯CDC
L
LangChain Blog
The Register - Security
The Register - Security
OSCHINA 社区最新新闻
OSCHINA 社区最新新闻
博客园 - 聂微东

博客园 - I'm CY

Graphviz(02) 汉字subgraph不显示汉字的处理 Graphviz(01) notepad++ Run xxx.gv How to design a product table for many kinds of product where each product has many parameters MVVM ICommand.CanExecute parameter is null Code First ef SQL Server 版本不支持数据类型“datetime2” 'System.ValueTuple, Version=0.0.0.0 required for Add-Migration on .NET 4.6.1 Class Library LDAP 相关链接 .NET WCF Return String 字符串有反斜杠的处理 word2010多级列表编号为什么会变成黑块 C# javascript 采用 RSA 加密解密 [LINK]List of .NET Dependency Injection Containers (IOC) 转:javascript判断IE浏览器 How to:Aborting a long running task in TPL How to: Cancel a Task and Its Children Exception has been thrown by the target of an invocation C#、IronPython、PowerShell 简单设计 大杀器 Linq手动添加EntitySet关系需要注意的地方
使用ContentPresenter,不使用ContentControl
I'm CY · 2018-12-18 · via 博客园 - I'm CY

参考: https://wpf.2000things.com/2017/04/06/1204-using-a-datatrigger-to-change-content-in-a-contentpresenter/

<Window.Resources>
    <DataTemplate x:Key="DefaultContent">
        <StackPanel>
            <TextBlock Margin="10" Text="Some default content here.."/>
            <TextBlock Margin="10" Text="Maybe show progress for operation"/>
        </StackPanel>
    </DataTemplate>
 
    <DataTemplate x:Key="AllDoneContent">
        <StackPanel>
            <TextBlock Margin="10" Text="** This is the ALL DONE content..."
                       Foreground="Green"/>
            <TextBlock Margin="10" Text="Put anything you like here"/>
            <Button Margin="10" Content="Click Me" HorizontalAlignment="Left"/>
        </StackPanel>
    </DataTemplate>
 
    <Style x:Key="MyContentStyle" TargetType="ContentPresenter">
        <Setter Property="ContentTemplate" Value="{StaticResource DefaultContent}"/>
        <Style.Triggers>
            <DataTrigger Binding="{Binding JobDone}" Value="True">
                <Setter Property="ContentTemplate" Value="{StaticResource AllDoneContent}"/>
            </DataTrigger>
        </Style.Triggers>
    </Style>
     
</Window.Resources>
 
<Grid Margin="10">
    <Grid.RowDefinitions>
        <RowDefinition Height="*"/>
        <RowDefinition Height="Auto"/>
        <RowDefinition Height="*"/>
    </Grid.RowDefinitions>
 
    <ContentPresenter Grid.Row="0" Style="{StaticResource MyContentStyle}" Content="{Binding}"/>
     
    <Separator Grid.Row="1"/>
 
    <CheckBox Grid.Row="2" Margin="10" Content="Mark job done" IsChecked="{Binding JobDone}"/>
</Grid>

 ContentControl通过DataTrigger进行切换模板时,原来绑定的模板会引发DataContext事件