Note that there are some explanatory texts on larger screens.

plurals
  1. POWPF: Switching window styles
    text
    copied!<p>I have a program that has some buttons, one of them is used to switch "Themes". There are two themes, one is the normal Windows theme and the other is called Style2.</p> <p>This is how I tried the switching</p> <pre><code> private bool UsingWindowsStyle = true; private ResourceDictionary Style2= new ResourceDictionary() { Source = new Uri("/...;component/Resources/DefaultStyles.xaml", UriKind.RelativeOrAbsolute) }; private void SwitchButton_Click(object sender, RoutedEventArgs e) { if (UsingWindowsStyle) { Resources.MergedDictionaries.Add(Style2); UsingWindowsStyle = false; } else { Resources.MergedDictionaries.Remove(Style2); UsingWindowsStyle = true; } } </code></pre> <p>My problem is, when I use this program, and press this <code>Button</code>, this is what happens:</p> <p><strong>Window Opened</strong> Program operating normally with Windows theme.</p> <p><strong>SwitchButton First Click</strong> Program changes visuals to the Style2 theme. All the program's buttons operating normally.</p> <p><strong>SwitchButton Second Click</strong> Program reverts back to Windows theme, but all the buttons in the program seize to work.</p> <p><em>Points to Consider</em></p> <ol> <li>The program does not throw any exceptions at this point.</li> <li>Debugging the code, it seems that after the second click, the program does not enter the <code>SwitchButton_Click</code> method.</li> <li><p>I tried readding the Click <code>EventHandler</code> but with no use.</p> <pre><code>SwitchButton.Click += new RoutedEventHandler(SwitchButton_Click); </code></pre></li> </ol> <p>Thanks in advance for your help.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload