在我的解决方案中,我有一个 UWP 应用程序和一个 UWP 类库(都针对 Windows 10 Build 10240)。
我在类库中添加了一个模板化控件。此控件继承自 Windows.UI.Xaml.Controls.Control,如下所示:
[TemplatePart(Name = GRID_CONTAINER_PART_NAME, Type = typeof(Grid))]
[TemplatePart(Name = CAPTURE_ELEMENTPREVIEW_PART_NAME, Type = typeof(CaptureElement))]
[TemplatePart(Name = CANVAS_PREVIEW_PART_NAME, Type = typeof(Canvas))]
[TemplatePart(Name = TEXTBLOCK_STATUS_PART_NAME, Type = typeof(TextBlock))]
public sealed class FaceDetectorPreview : Control
(我选择从模板化控件派生,以便控件可部署到不同的应用程序,并使开发人员能够更改组件的外观和感觉)
在应用程序中,我可以将控件添加到 XAML 页面,运行应用程序,一切正常。
但是,在设计器中,当我选择“编辑模板”时,“编辑副本”菜单项被禁用。
问:我需要更改哪些内容才能使“编辑副本”菜单项可用?
Generic.xaml 中的代码如下所示:
<ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="using:FaceDetection.Controls">
<Style TargetType="local:FaceDetectorPreview">
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="local:FaceDetectorPreview">
<Grid x:Name="PART_GridContainer">
<CaptureElement x:Name="PART_CaptureElementPreview" />
<Canvas x:Name="PART_CanvasPreview" />
<TextBlock x:Name="PART_TextBlockStatus" />
</Grid>
</ControlTemplate>
</Setter.Value>
</Setter>
</Style>