i have a button that should show some content If the name_checked
return true
• C# :
private bool name_checked = false; // <<--------#
private string username = "Smith";
private string message = null;
public MainWindow() {
if (username == "Josh"){
name_checked = true; // <<--------# if right true
message = "Welcome Josh";
}
private void button__Click(object sender, RoutedEventArgs e) {
if ( name_checked == true ) MessageBox.Show(message);
}
• wpf xaml :
<Button Name="anyname" Click="button__Click"
Width="100" Height="50" HorizontalAlignment="Right"
Margin="0,4,154,0" VerticalAlignment="Top" Grid.Row="2" Grid.RowSpan="2" />
└─ output Error : (InvalidOperationExction was unhandled
)
What i want is : to stop the Button from acting if the the Boolean
name_checked
return false
i dont want any message to show at all if the Boolean return false , even Errors
- so am using it correct or not ?? . if not please show me the right way.