我在app.xaml中有一个DataTemplate,它将视图绑定到viewmodel.
<Application.Resources>
<DataTemplate DataType="{x:Type vm:someviewmodeltype}">
<vw:somevwcontrol />
</DataTemplate>
</Application.Resources>
Run Code Online (Sandbox Code Playgroud)
如果没有样式,则不会应用上述模板.我放风格的那一刻,像...
<Application.Resources>
<DataTemplate DataType="{x:Type vm:someviewmodeltype}">
<vw:somevwcontrol />
</DataTemplate>
<Style TargetType="TextBlock">
<Setter Property="FontSize" Value="20"></Setter>
</Style>
</Application.Resources>
Run Code Online (Sandbox Code Playgroud)
datatemplate被拿起并产生预期的结果......我不确定那里发生了什么......有人可以澄清一下吗?
谢谢.