C# WPF Control with transparent background

  1. //Set background color
  2. mycontrol.Background = Brushes.Green;
  3. //Not transparent
  4. mycontrol.Opacity=1;
  5. //Half transparent
  6. mycontrol.Opacity=0.5;

How to add a CheckBox to a Menu Item in WPF

xaml
  1. <MenuItem IsCheckable="True" x:Name="_showSolutionExplorer" Header="Solution Explorer" Click="_showContent_Click"></MenuItem>  

c#
  1. private void _showContent_Click(object sender, RoutedEventArgs e)   
  2. {   
  3.     If ((sender as MenuItem).IsChecked)   
  4.         MessageBox.Show("MenuItem is checked");   
  5.     else   
  6.         MessageBox.Show("MenuItem is not checked");   
  7. }  

C# Write and read config file

app.config

  1. <?xml version="1.0"?>  
  2. <configuration>  
  3.   <appSettings>  
  4.     <add key="oldPlace" value="4" />  
  5.   </appSettings>  
  6. </configuration>  

Write:


  1. System.Configuration.Configuration config =ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);  
  2. config.AppSettings.Settings["oldPlace"].Value = "3";       
  3. config.Save(ConfigurationSaveMode.Modified);  
  4. ConfigurationManager.RefreshSection("appSettings");  

Read:

  1. string value = ConfigurationManager.AppSettings["oldPlace"];