Skip to content

Instantly share code, notes, and snippets.

@christian289
Created September 14, 2023 09:00
Show Gist options
  • Save christian289/29dc5e9690fa23bfeaecd975e10e0155 to your computer and use it in GitHub Desktop.
Save christian289/29dc5e9690fa23bfeaecd975e10e0155 to your computer and use it in GitHub Desktop.
WPF Popup 컨트롤이 StaysOpen=True 상태로 다른 프로세스의 Window에 포커스를 주면 Popup 컨트롤 안에 있는 TextBox에 Cursor가 옮겨지지 않는다. Popup을 닫고 다시 열면 Cursor가 생긴다.
<Window x:Class="WpfApp1.MainWindow"
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:local="clr-namespace:WpfApp1"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
Title="MainWindow"
Width="800"
Height="450"
mc:Ignorable="d">
<Grid>
<Button x:Name="btn"
Width="100"
Height="50"
Click="Button_Click"
Content="팝업 오픈" />
<Popup x:Name="popup"
IsOpen="False"
Placement="Bottom"
PlacementTarget="{Binding ElementName=btn}"
StaysOpen="True">
<Border Background="blue">
<Grid>
<TextBox x:Name="tb" Width="200" />
</Grid>
</Border>
</Popup>
</Grid>
</Window>
using System.Windows;
namespace WpfApp1
{
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
}
private void Button_Click(object sender, RoutedEventArgs e)
{
popup.IsOpen = true;
}
}
}
@christian289
Copy link
Author

https://forum.dotnetdev.kr/t/wpf-popup/8296?u=vincent

여기에 의견이 달려있습니다.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment