Note that there are some explanatory texts on larger screens.

plurals
  1. POIn XAML, What is the correct XML namespace for VisualStateManager?
    primarykey
    data
    text
    <p>I'm trying to restyle a few ToggleButtons. Apparently I cannot simply set the background to a new color, because there is a "Control Template" that provides the ToggleButton's visual behavior. So what I need to do is specify in XAML a replacement "ControlTemplate" for the ToggleButton that provides different visual behavior, beyond the simple background color.<br> <strong>Q1</strong>. Is this correct? </p> <hr> <p>I figured to start with the "default" controltemplate for the ToggleButton, which I grabbed <a href="http://msdn.microsoft.com/en-us/library/cc296245%28v=VS.95%29.aspx" rel="nofollow noreferrer">from here</a>, and then modify it. Actually that is the default ControlTemplate for Silverlight, I guess, and I am not using Silverlight, I'm using WPF. But... <a href="http://msdn.microsoft.com/en-us/library/ff468212.aspx" rel="nofollow noreferrer">The corresponding doc page for WPF</a> does not include a specification of the default controltemplate. It provides "a" ControlTemplate, which is not what I want.<br> <strong>Q2</strong>. I'm not sure if it matters that I am using the thing from Silverlight. Does it?</p> <hr> <p>In the Silverlight example, there is an XML namespace prefix of of vsm applied to the VisualStateManager. Apparently the xml namespace is </p> <pre><code> xmlns:vsm = "clr-namespace:System.Windows;assembly=System.Windows" </code></pre> <p>... but somewhere else I read that this XML namespace "is no longer necessary." </p> <p>This is all very very confusing. </p> <p>In the Googlespace, <a href="http://www.codeproject.com/KB/smart/SongBird.aspx" rel="nofollow noreferrer">there are references to something called "The WPF toolkit"</a> which I have had prior exposure to - <a href="https://stackoverflow.com/q/2338690/48082">I used it for an autocomplete textbox</a> prior to the release of WPF V4. I am guessing that some of the WPF Toolkit stuff was rolled into WPF for .NET v4.0, and that is why I no longer have to specify the WPF toolkit.<br> <strong>Q3</strong>. If someone could confirm that understanding I'd appreciate it.</p> <hr> <p>Ok, now starting with the "default" ControlTemplate for ToggleButton, my first step was to compile it, before making any changes. It does not compile, failing with</p> <blockquote> <p>c:\dev...\ToggleButtonStyle1.xaml(23,14): error MC3074: The tag 'VisualStateManager.VisualStateGroups' does not exist in XML namespace '<a href="http://schemas.microsoft.com/winfx/2006/xaml/presentation" rel="nofollow noreferrer">http://schemas.microsoft.com/winfx/2006/xaml/presentation</a>'. Line 23 Position 14. </p> </blockquote> <p>Clear enough. I then looked at the documentation for specifying VisualStateManager in XAML. It, confusingly enough, specifies two xml namespaces, one of them is the one I actually used. </p> <p><img src="https://i.stack.imgur.com/PiCjj.png" alt="enter image description here"></p> <p><strong>Q4</strong> Um, which of these am I supposed to use? One of them, I DID use, and it didn't work. The documentation is completely unclear on what it means to specify <em>TWO XML namespaces</em>. (off with their heads!)</p> <p>I have a reference to PresentationFramework.dll in the project file: </p> <pre><code> &lt;ItemGroup&gt; .... &lt;Reference Include="PresentationFramework" /&gt; &lt;/ItemGroup&gt; </code></pre> <p>I am not using Visual Studio here; I'm using a text editor. I want to understand how it works, not what buttons to push. </p> <p>Thanks for any help y'all can provide.</p> <hr> <p>Just a side comment - this all seems very very complicated. All I want to do is change the color of a ToggleButton when it is ON. It really shouldn't be this complicated. </p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

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