可以将clr:string的DynamicResource绑定到另一个来源而不是文字? [英] Is it possible to bind a DynamicResource of clr:string to another source instead of literal?
本文介绍了可以将clr:string的DynamicResource绑定到另一个来源而不是文字?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
<Window x:Class="WpfTutorialSamples.WPF_Application.ResourceSample"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:sys="clr-namespace:System;assembly=mscorlib">
<Window.Resources>
<sys:String x:Key="centralRes">Hello, world!</sys:String>
</Window.Resources>
<StackPanel Margin="10">
<TextBox Name="src" />
<TextBlock Name="dst" Text="{DynamicResource centralRes}" FontSize="56" />
</StackPanel>
</Window>
我刚刚学习,好奇如果我可以绑定 / code>文字在
centralRes
到另一个控件的Text属性(如 src.Text
),所以当它更新,所有的东西都像 dst
自动更新。
I am just learning, and was curious if I can bind the string
literal in centralRes
to another control's Text property (like src.Text
), so when it updates, all things bound to it like dst
automatically update.
几乎像一个信息的中心枢纽。这是可能吗?
Almost like a central hub for a piece of info. Is this possible to do?
我想要的例子:
<sys:String x:Key="centralRes" Value="{Binding Text, ElementName=src}">Hello, world!</sys:String>
推荐答案
{StaticResource centralRes}
Use StaticResource instead ie. {StaticResource centralRes}
这篇关于可以将clr:string的DynamicResource绑定到另一个来源而不是文字?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文