I guess you can't show a `ContentDialog` and a `TeachingTip` at the same time. Let me show you another way to do this by creating a custom dialog based on a `Window`:
**CustomDialog.cs**
```cs
using Microsoft.UI.Xaml;
using System.Threading.Tasks;
using WinUIEx;
namespace App1;
public enum CustomDialogResult
{
Cancel,
OK,
}
public partial class CustomDialog : WindowEx
{
private TaskCompletionSource<CustomDialogResult>? _taskCompletionSource;
public CustomDialog()
{
this.InitializeComponent();
this.IsAlwaysOnTop = true;
this.CenterOnScreen();
this.SetWindowStyle(WindowStyle.Caption);
}
public new object? Content { get; set; }
public Task<CustomDialogResult> ShowAsync()
{
this.ContentPresenter.Content = Content;
_taskCompletionSource = new();
this.Activate();
return _taskCompletionSource.Task;
}
private void OKButton_Click(object sender, RoutedEventArgs e)
{
_taskCompletionSource?.SetResult(CustomDialogResult.OK);
this.Close();
}
private void CancelButton_Click(object sender, RoutedEventArgs e)
{
_taskCompletionSource?.SetResult(CustomDialogResult.Cancel);
this.Close();
}
}
```
**CustomDialog.xaml.cs**
```xaml
<ex:WindowEx
x:Class="App1.CustomDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ex="using:WinUIEx"
xmlns:local="using:App1"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Width="300"
Height="200"
mc:Ignorable="d">
<Grid
RowDefinitions="*,Auto">
<ContentPresenter
x:Name="ContentPresenter"
Grid.Row="0" />
<Grid
Grid.Row="1"
ColumnDefinitions="*,*">
<Button
Grid.Column="0"
Click="OKButton_Click"
Content="OK" />
<Button
Grid.Column="1"
Click="CancelButton_Click"
Content="Cancel" />
</Grid>
</Grid>
</ex:WindowEx>
```
then use it like this:
```cs
public sealed partial class MainWindow : Window
{
public MainWindow()
{
this.InitializeComponent();
}
private async void Button_Click(object sender, RoutedEventArgs e)
{
TextBlock text = new() { Text = "Hello world" };
TeachingTip teachingTip = new()
{
Content = "This is a sample teaching tip.",
Title = "Sample Teaching Tip",
Target = text,
IsOpen = true,
};
CustomDialog dialog = new();
dialog.Content = new StackPanel()
{
Children =
{
text,
teachingTip
}
};
CustomDialogResult result = await dialog.ShowAsync();
}
}
```
**NOTE:**
I'm using the [WinUIEx](https://github.com/dotMorten/WinUIEx) NuGet package here but you should be able to do this without it.
Since it seems that it's a bit difficult to do this with the `ContentDialog`, let me show you another way that should be something close to what you are looking for:
**CustomDialog.cs**
```cs
using Microsoft.UI.Xaml;
using System.Threading.Tasks;
using WinUIEx;
namespace App1;
public enum CustomDialogResult
{
Cancel,
OK,
}
public partial class CustomDialog : WindowEx
{
private TaskCompletionSource<CustomDialogResult>? _taskCompletionSource;
public CustomDialog()
{
this.InitializeComponent();
this.IsAlwaysOnTop = true;
this.CenterOnScreen();
this.SetWindowStyle(WindowStyle.Caption);
}
public new object? Content { get; set; }
public Task<CustomDialogResult> ShowAsync()
{
this.ContentPresenter.Content = Content;
_taskCompletionSource = new();
this.Activate();
return _taskCompletionSource.Task;
}
private void OKButton_Click(object sender, RoutedEventArgs e)
{
_taskCompletionSource?.SetResult(CustomDialogResult.OK);
this.Close();
}
private void CancelButton_Click(object sender, RoutedEventArgs e)
{
_taskCompletionSource?.SetResult(CustomDialogResult.Cancel);
this.Close();
}
}
```
**CustomDialog.xaml.cs**
```xaml
<ex:WindowEx
x:Class="App1.CustomDialog"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:ex="using:WinUIEx"
xmlns:local="using:App1"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Width="300"
Height="200"
mc:Ignorable="d">
<Grid
RowDefinitions="*,Auto">
<ContentPresenter
x:Name="ContentPresenter"
Grid.Row="0" />
<Grid
Grid.Row="1"
ColumnDefinitions="*,*">
<Button
Grid.Column="0"
Click="OKButton_Click"
Content="OK" />
<Button
Grid.Column="1"
Click="CancelButton_Click"
Content="Cancel" />
</Grid>
</Grid>
</ex:WindowEx>
```
and use it like this:
```cs
public sealed partial class MainWindow : Window
{
public MainWindow()
{
this.InitializeComponent();
}
private CustomDialog? CustomDialog { get; set; }
private async void Button_Click(object sender, RoutedEventArgs e)
{
CustomDialog = new()
{
Title = "Title",
Content = "Are you ready?",
};
this.RootGrid.PointerPressed += RootGrid_PointerPressed;
CustomDialogResult result = await CustomDialog.ShowAsync();
this.RootGrid.PointerPressed -= RootGrid_PointerPressed;
(sender as Button)!.Content = result.ToString();
}
private void RootGrid_PointerPressed(object sender, Microsoft.UI.Xaml.Input.PointerRoutedEventArgs e)
{
CustomDialog?.Close();
}
}
```
The code above should have some missing features, but I hope it gives you some direction.
**NOTE:**
I'm using the [WinUIEx](https://github.com/dotMorten/WinUIEx) NuGet package here but you should be able to do this without it.