Удивительно, но я не смог найти способ сделать это красиво.
Если вы не можете найти путь в .NET, вы можете сделать это через p / invoke.
[DllImport("user32.dll", CharSetCharSet = CharSet.Auto, SetLastError = false)]
static extern IntPtr SendMessage(IntPtr hWnd, Int32 Msg, IntPtr wParam, IntPtr lParam);
private const int CB_SHOWDROPDOWN = 0x014F;
SendMessage(FieldDescription.Handle, CB_SHOWDROPDOWN, (IntPtr)1, (IntPtr)0);
Вы можете поместить его в событие OnFocus
.
Ссылка от gcores имеет ответ, который состоит в том, чтобы поместить границу и ее содержимое в одну сетку, чтобы содержимое перекрывало границу.
<Window x:Class="WpfEffectTest.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Grid>
<Border BorderBrush="Black" BorderThickness="10" CornerRadius="5" Margin="25">
<Border.Effect>
<DropShadowEffect BlurRadius="10" ShadowDepth="5" />
</Border.Effect>
</Border>
<StackPanel Margin="35">
<TextBlock>This is some text</TextBlock>
<TextBlock>This is some text</TextBlock>
<TextBlock>This is some text</TextBlock>
<TextBlock>This is some text</TextBlock>
<TextBlock>This is some text</TextBlock>
<TextBlock>This is some text</TextBlock>
</StackPanel>
</Grid>
</Window>
One simple (hack?) solution is to do
<StackPanel Background="White">
This should solve the text with drop-shadow problem (Not sure about the performance problem though). The problem is that WPF applies effects to the set element and all it's children in the visual tree. This link explains it better: Проблема производительности DropShadowEffect