Reputation: 25583
SL 4 provides a dialog box by MessageBox, but MessageBoxButton only provide option for button as OK, Cancel. How to change it to YES, NO button?
Upvotes: 1
Views: 4141
Reputation: 5282
Your best bet is to use the System.Windows.Controls.Primitives.Popup
<Grid x:Name="LayoutRoot" Background="White">
<Button x:Name="showPopup" Click="showPopup_Click" Height="100" Width="100" Content="Show Popup"/>
<Popup x:Name="myPopup" IsOpen="False" VerticalAlignment="Top" HorizontalAlignment="Center" >
<Canvas Height="200" Width="300" Background="Azure">
<Button x:Name="closePopup" Click="closePopup_Click" Height="50" Width="100" Content="Close Popup"/>
</Canvas>
</Popup>
<Canvas x:Name="myCanvas" Visibility="Collapsed" Background="Black" Opacity=".4"></Canvas>
</Grid>
public partial class Page : UserControl
{
public Page()
{
InitializeComponent();
}
private void closePopup_Click(object sender, RoutedEventArgs e)
{
myPopup.IsOpen = false;
myCanvas.Visibility = Visibility.Collapsed;
}
private void showPopup_Click(object sender, RoutedEventArgs e)
{
myPopup.IsOpen = true;
myCanvas.Visibility = Visibility.Visible;
}
}
If you don't want to create your own popup, there probably are 3rd party messageboxes, but with this solution, you have eveything in your own hands.
Upvotes: 0
Reputation: 7612
This MessageBox built into silverlight can't be changed beyond the capabilities that are exposed.
Your only solution would be to make a custom ChildWindow class which provides the functionality you want. There are many examples of this.
This has the advantage of acting more like other silverlight popup windows, and can be themed and skinned however you'd like, with whatever buttons and functionality you chose to implement.
This has the disadvantage that you are forced then to use a callback model rather than an a more usual imperative flow control.
Upvotes: 1