如何为uname -r
4.2.0-35-generic
中定义的Controls/Templates
撰写活动?
现在我使用ResourceDictionary
并在event to command strategy
中为每个控件和每个Commands
写ViewModels(DataContext)
。请参阅下面的代码,如何在event
中编写TextChanged
事件:
ResourceDictionary
答案 0 :(得分:0)
为此,我们需要使用ResourceDictionary
:
x:class
编写一个类文件
public partial class ResourceDictionary
{
//...
}
并需要在class
中指定ResourceDictionary
:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
x:Class="YourNamespace.ResourceDictionary"
>
<Style TargetType="{x:Type TextBox}" x:Key="MyTextBox">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate>
<TextBox Width="500" Background="LightGreen" TextChanged="TextChanged" />
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>