Xaml 为UWP应用程序实现教学IP控制

Xaml 为UWP应用程序实现教学IP控制,xaml,uwp,nuget,win-universal-app,uwp-xaml,Xaml,Uwp,Nuget,Win Universal App,Uwp Xaml,要在我的UWP应用程序中安装-控件,我已完成以下步骤: 在我的项目中通过Nuget安装了Microsoft.UI.Xaml软件包 将添加到App.xaml中 导入的命名空间xmlns:controls=“使用:Microsoft.UI.Xaml.controls” 我实施了教学IP-控制,如下所示: <Button x:Name="BackButton" Background="{x:Null}" Content="Back" Click="

要在我的UWP应用程序中安装-控件,我已完成以下步骤:

  • 在我的项目中通过Nuget安装了
    Microsoft.UI.Xaml
    软件包
  • 添加到
    App.xaml
  • 导入的命名空间
    xmlns:controls=“使用:Microsoft.UI.Xaml.controls”
  • 我实施了教学IP-控制,如下所示:

    <Button x:Name="BackButton"
            Background="{x:Null}"
            Content="Back"
            Click="BackButton_Click">
        <Button.Resources>
            <controls:TeachingTip x:Name="ToggleThemeTeachingTip"
                                  Target="{x:Bind BackButton}"
                                  Title="Change themes without hassle"
                                  Subtitle="It's easier than ever to see control samples in both light and dark theme!"
                                  CloseButtonContent="Got it!">
            </controls:TeachingTip>
        </Button.Resources>
    </Button>
    
    <Button x:Name="TeachingTipButton"
            Click="TeachingTipButton_OnClick">
    </Button>
    
    
    private void TeachingTipButton_OnClick(object sender, RoutedEventArgs e)
    {
        ToggleThemeTeachingTip.IsOpen = true;
    }
    
    如果我给资源条目一个键,如下所示:

    <XamlControlsResources x: Key = "XamlControlsResources" xmlns = "using: Microsoft.UI.Xaml.Controls" />
    
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
            </ResourceDictionary.MergedDictionaries>
            <!-- Other styles here -->
            <Style TargetType="Button">
              ...
            </Style>
        </ResourceDictionary>
    </Application.Resources>
    

    如何在我的App.xaml中正确地添加资源?

    我将您的代码粘贴到我的项目中,它成功了。但是,上面提供的代码没有触发按钮的内容,因此显示的唯一按钮是顶部按钮。您确定没有因为
    BackButton\u Click
    中的代码而失败,而不是单击
    teachingtiputton\u OnClick


    您可以从
    应用程序.Resources

    中删除对
    Microsoft.UI.Xaml.控件的重复引用
    ,我通过删除ContentDialog大小样式和默认按钮样式解决了我的问题,这样
    只有
    作为一个条目。在我的情况下,
    中的多个条目不幸不被接受。

    您的App.xaml文件需要如下所示:

    <XamlControlsResources x: Key = "XamlControlsResources" xmlns = "using: Microsoft.UI.Xaml.Controls" />
    
    <Application.Resources>
        <ResourceDictionary>
            <ResourceDictionary.MergedDictionaries>
                <XamlControlsResources xmlns="using:Microsoft.UI.Xaml.Controls" />
            </ResourceDictionary.MergedDictionaries>
            <!-- Other styles here -->
            <Style TargetType="Button">
              ...
            </Style>
        </ResourceDictionary>
    </Application.Resources>
    
    
    ...
    
    您能提供一份回购协议或代码来说明您的问题吗?@visc,请查看我的编辑。project的目标和最低版本是什么?和操作系统构建版本?@XavierXie MSFT,Windows 10,版本1809(10.0;构建17763)这不是由于功能故障。按钮事件运行良好,我在app.xaml中没有重复的按钮事件。我想我的app.xaml中有语法错误。