我在我的通用Windows应用程序创建一个模板化控件。
问题是,在<Button Content="{Binding}" Command="{TemplateBinding AddCharCommand}" />
的TemplateBinding
不起作用。
看来这个问题是因为它是一个DataTemplate
中定义。
这是Style
并应用到我的控制模板。
<Style TargetType="local:CoordinatesControl">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:CoordinatesControl">
<ListView ItemsSource="{TemplateBinding Numbers}">
<ListView.ItemTemplate>
<DataTemplate>
<Button Content="{Binding}"
Command="{TemplateBinding AddCharCommand}" />
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>