【发布时间】:2014-05-13 19:48:17
【问题描述】:
请考虑以下 XAML 标记(Visual Studio 2010 中的 App.xaml 文件):
<Application x:Class="UpdateTrigger.App"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:UpdateTrigger"
xmlns:clr="clr-namespace:System;assembly=mscorlib"
StartupUri="MainWindow.xaml">
<Application.Resources>
<clr:String x:Key="MyString">My string</clr:String>
</Application.Resources>
</Application>
我可以像 C# 程序中的变量一样写入MyString 吗?这就是我想要做的:我试图通过纯 XAML 声明和定义一个变量,没有任何代码隐藏。这可能吗?
澄清编辑:
例如,如果我将MyString 绑定到 XAML 中的文本框,用户可以在该文本框中键入内容吗?我试过了,但没能做到。
【问题讨论】:
-
你要这个干什么?
-
@HighCore:请参阅编辑。
-
eehmm...你要这个干什么?
-
我正在尝试让这里的示例正常工作:msdn.microsoft.com/en-us/library/…