在 wpf 中使用 TargetType 作为第三方控件

Use TargetType as third party control in wpf

我正在为我的 WPF 应用程序使用 Mahapps.Metro UI。 我想修改Mahapps提供的Tile控件来满足我的需求。所以我决定为它制作 ControlTemplate。但我无法将 TargetType 称为第三方控件的 Tile 控件。你能帮我解决这个问题吗?

1) 首先你需要在你的项目中引用他们的程序集。 2) 您需要在根目录中包含 xaml 命名空间(Window、ResourceDictionary 或任何您想编写模板的地方)

喜欢,

xmlns:controls="clr-namespace:MahApps.Metro.Controls;assembly=MahApps.Metro"

然后使用模板中的类型

<ControlTemplate TargetType={x:Type controls:TileControl}>
   <!--your template-->
</ControlTemplate >