无法在WPF中打开弹出窗口

时间:2015-06-19 11:22:01

标签: wpf vb.net telerik

所以,我正在尝试创建一个日历弹出窗口,一旦文本框获得焦点就会打开。以下是我正在使用的代码。

                            <TextBox x:Name="CalendarTextBox" BorderBrush="#CCCCCCCC" Foreground="#FF777777" HorizontalAlignment="Right" Width="305" Height="30" VerticalContentAlignment="Center" Panel.ZIndex="10" Margin="0,10,10,0" VerticalAlignment="Top" SelectionBrush="#FF0081A7" BorderThickness="2" GotFocus="CalendarTextBox_GotFocus" LostFocus="CalendarTextBox_LostFocus"/>
                        <Popup x:Name="PopUpCalendar" PlacementTarget="{Binding ElementName=CalendarTextBox}" StaysOpen="False" Width="305" Height="305" Panel.ZIndex="200">
                            <telerik:RadCalendar HorizontalAlignment="Left" VerticalAlignment="Bottom" Orientation="Vertical" AreWeekNamesVisible="False" Width="305" Height="305">
                                <telerik:StyleManager.Theme>
                                    <telerik:Windows8Theme/>
                                </telerik:StyleManager.Theme>
                            </telerik:RadCalendar>
                        </Popup>

代码背后:

    Private Sub CalendarTextBox_GotFocus(sender As Object, e As RoutedEventArgs)
    PopUpCalendar.IsOpen = True
End Sub

Private Sub CalendarTextBox_LostFocus(sender As Object, e As RoutedEventArgs)
    PopUpCalendar.IsOpen = False
End Sub

类似的代码适用于页面中的其他弹出窗口。但不知何故日历根本没有显示。奇怪的是,代码正确执行,但在此之后,页面上没有日历弹出窗口。我无法弄清楚我错过了什么。我甚至将Zindex增加到了很高的数字。

1 个答案:

答案 0 :(得分:0)

原来保持开放财产造成了问题。我将其设置为true并且有效。现在两个事件都按预期发射。