Reputation: 293
Hey so I have this code bellow which gives the following errors, Can anyone explain what my problem is please.
Error 2 'System.Nullable<bool>' does not contain a definition
for 'Yes' and no extension method 'Yes' accepting a first argument of type
'System.Nullable<bool>' could be found (are you missing a using directive or an assembly
reference?)
var dialogResult = MessageBox.Show("Sure", "Some Title", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (dialogResult == DialogResult.Yes)
{
tw.hashtagList(body);
}
else if (dialogResult == DialogResult.No)
{
var dialogResult2 = MessageBox.Show("Sure", "Some Title", MessageBoxButton.YesNo, MessageBoxImage.Question);
if (dialogResult2 == DialogResult.Yes)
{
tw.mentionList(body);
}
}
Upvotes: 1
Views: 1213
Reputation: 1624
Is this a Windows Applicataion?
then replace
`MessageBoxButton.YesNo` and MessageBoxImage
with
MessageBoxButtons.YesNo and MessageBoxIcon
Upvotes: 0
Reputation: 1809
in WPF MessageBox
is in System.Windows
namespace and
MessageBox.Show
returns result with type of MessageBoxResult
Upvotes: 1
Reputation: 825
It seem to me that you are using WPF.
WPF message box differs from Windows forms one. Here are WPF message box example:
void showMessageBoxButton_Click(object sender, RoutedEventArgs e) {
// Configure message box
string message = "Hello, MessageBox!";
string caption = "Caption text";
MessageBoxButton buttons = MessageBoxButton.OKCancel;
MessageBoxImage icon = MessageBoxImage.Information;
// Show message box
MessageBoxResult result = MessageBox.Show(message, caption, buttons, icon);
}
For more information follow the MSDN link: http://msdn.microsoft.com/en-us/library/ms602949.aspx
Upvotes: 0