Reputation: 496
I want to open a DatePicker from a popup. When I click the datepicker, the date input page (the one with spinners) opens behind the Popup.
How can the DatePicker go over the popup window and return to it after I select the date?
This is how I open the popup:
private void btnShowBuyNow_Click(object sender, RoutedEventArgs e)
{
Popup buyNowScreen;
buyNowScreen = new Popup();
buyNowScreen.Child =
new BuyNowScreen
("Buy this application and get rid of the ads!");
buyNowScreen.IsOpen = true;
buyNowScreen.VerticalOffset = 100;
buyNowScreen.HorizontalOffset = 25;
buyNowScreen.Closed += (s1, e1) =>
{
// Add you code here to do something
// when the Popup is closed
};
}
DatePicker in the popup's xaml file:
<toolbox:DatePicker x:Name="DatePick" Height="Auto" HorizontalAlignment="Center" Margin="0,0,0,0" VerticalAlignment="Top" Width="400" IsEnabled="True"/>
Upvotes: 0
Views: 1109
Reputation: 5325
With Events:
Add a button in your PopUp with the DatePicker. When the button is clicked have an event to close the PopUp
<toolbox:DatePicker x:Name="DatePick" Height="Auto" HorizontalAlignment="Center" Margin="0,0,0,0" VerticalAlignment="Top" Width="400" IsEnabled="True"/>
<Button Click="DateAcceptedClick"/>
public event DateAcceptedButtonClick DateAcceptedButtonEvent;
public delegate void DateAcceptedButtonClick (object sender, RoutedEventArgs e);
private void DateAcceptedClick(object sender, RoutedEventArgs e)
{
if (DateAcceptedButtonEvent!= null)
DateAcceptedButtonEvent(sender, e);
}
Popup BuyNowScreen;
private void btnShowBuyNow_Click(object sender, RoutedEventArgs e)
{
BuyNowScreen = new Popup();
BuyNowScreen.Child = new BuyNowScreen("Buy this application and get rid of the ads!");
BuyNowScreen.IsOpen = true;
BuyNowScreen.VerticalOffset = 100;
BuyNowScreen.HorizontalOffset = 25;
BuyNowScreen.DateAcceptedButtonEvent += new DateAcceptedButtonClick(PopupDateAcceptedButtonClick)
}
private void PopupDateAcceptedButtonClick(object sender, RoutedEventArgs e)
{
BuyNowScreen.IsOpen = false;
//Closed logic
}
Upvotes: 1