How to set the Visibility of an control from Resources.resx file?Hi,<br><br>I'm trying to get the visibility value of a button from the resources.resx file. I'm getting error as &quot;Cannot convert the string value to Visibility.Collapsed&quot; . Here my code as follows,<br><br>XAML Code:-<br><font color="#a31515" size=2> <p><font color="#0000ff" size=2></p> <p>&lt;</font><font color="#a31515" size=2>Button</font><font color="#ff0000" size=2> Margin</font><font color="#0000ff" size=2>=&quot;64,110,69,123&quot;</font><font color="#ff0000" size=2> Name</font><font color="#0000ff" size=2>=&quot;button2&quot;</font><font color="#ff0000" size=2> Content</font><font color="#0000ff" size=2>=&quot;{</font><font color="#a31515" size=2>x</font><font color="#0000ff" size=2>:</font><font color="#a31515" size=2>Static</font><font color="#ff0000" size=2> properties</font><font color="#0000ff" size=2>:</font><font color="#ff0000" size=2>Resource1</font><font color="#0000ff" size=2>.MainButtonContent}&quot;</font><font size=2> </font><font color="#ff0000" size=2>Visibility</font><font color="#0000ff" size=2>=&quot;{x:Static properties:Resource1.MainButtonVisibility}&quot; /&gt;<br><br>Resources.resx Code:-<br><br><font color="#000000">Name                    Value</font><br>MainButtonVisibility Collapsed <br><br><font color="#000000">In the Output window the control should not appear, as per the above code. But the button is appearing in the window. As well as in the above code i have done for the Content of the Button its working fine for me.<br></font><br><font color="#000000"> But the Visibility is not working, or am I did any mistakes on the code. Please correct me if I'm wrong.<br> I have tried so many ways to resolve the above issue. but I couldn't Please any can give me the guidence or code samples would be greatly appericiate.<br><br>Please let me know if more inputs required for the same.<br></font><br>Thanks and Best Regards,<br>Karthikeyan Manickam.<br></p></font></font>© 2009 Microsoft Corporation. All rights reserved.Mon, 29 Dec 2008 06:17:02 Z8c72e5de-f597-46bc-b429-59ec73fe830chttp://social.msdn.microsoft.com/Forums/en-US/vs2010ctpwpfdata/thread/8c72e5de-f597-46bc-b429-59ec73fe830c#8c72e5de-f597-46bc-b429-59ec73fe830chttp://social.msdn.microsoft.com/Forums/en-US/vs2010ctpwpfdata/thread/8c72e5de-f597-46bc-b429-59ec73fe830c#8c72e5de-f597-46bc-b429-59ec73fe830cKarthikeyanManickamhttp://social.msdn.microsoft.com/Profile/en-US/?user=KarthikeyanManickamHow to set the Visibility of an control from Resources.resx file?Hi,<br><br>I'm trying to get the visibility value of a button from the resources.resx file. I'm getting error as &quot;Cannot convert the string value to Visibility.Collapsed&quot; . Here my code as follows,<br><br>XAML Code:-<br><font color="#a31515" size=2> <p><font color="#0000ff" size=2></p> <p>&lt;</font><font color="#a31515" size=2>Button</font><font color="#ff0000" size=2> Margin</font><font color="#0000ff" size=2>=&quot;64,110,69,123&quot;</font><font color="#ff0000" size=2> Name</font><font color="#0000ff" size=2>=&quot;button2&quot;</font><font color="#ff0000" size=2> Content</font><font color="#0000ff" size=2>=&quot;{</font><font color="#a31515" size=2>x</font><font color="#0000ff" size=2>:</font><font color="#a31515" size=2>Static</font><font color="#ff0000" size=2> properties</font><font color="#0000ff" size=2>:</font><font color="#ff0000" size=2>Resource1</font><font color="#0000ff" size=2>.MainButtonContent}&quot;</font><font size=2> </font><font color="#ff0000" size=2>Visibility</font><font color="#0000ff" size=2>=&quot;{x:Static properties:Resource1.MainButtonVisibility}&quot; /&gt;<br><br>Resources.resx Code:-<br><br><font color="#000000">Name                    Value</font><br>MainButtonVisibility Collapsed <br><br><font color="#000000">In the Output window the control should not appear, as per the above code. But the button is appearing in the window. As well as in the above code i have done for the Content of the Button its working fine for me.<br></font><br><font color="#000000"> But the Visibility is not working, or am I did any mistakes on the code. Please correct me if I'm wrong.<br> I have tried so many ways to resolve the above issue. but I couldn't Please any can give me the guidence or code samples would be greatly appericiate.<br><br>Please let me know if more inputs required for the same.<br></font><br>Thanks and Best Regards,<br>Karthikeyan Manickam.<br></p></font></font>Tue, 16 Dec 2008 10:21:37 Z2008-12-16T10:21:37Zhttp://social.msdn.microsoft.com/Forums/en-US/vs2010ctpwpfdata/thread/8c72e5de-f597-46bc-b429-59ec73fe830c#511340e6-3a3a-474d-b192-84b1ff3b749ehttp://social.msdn.microsoft.com/Forums/en-US/vs2010ctpwpfdata/thread/8c72e5de-f597-46bc-b429-59ec73fe830c#511340e6-3a3a-474d-b192-84b1ff3b749eDev_DotNethttp://social.msdn.microsoft.com/Profile/en-US/?user=Dev_DotNetHow to set the Visibility of an control from Resources.resx file? Hi..What you are doing is setting a string valu to the Visibility attribute, which will result in this error. <br>Here you should use Converters. <br><br>Try something like this: <br><br>&lt;local:StringToVisibilityConverter x:Key=&quot;<font color="#000000">StringToVisibilityConverter</font>&quot; /&gt;<br><font color="#a31515" size=2> <p><font color="#0000ff" size=2></p> <p>&lt;</font><font color="#a31515" size=2>Button</font><font color="#ff0000" size=2> Margin</font><font color="#0000ff" size=2>=&quot;64,110,69,123&quot;</font><font color="#ff0000" size=2> Name</font><font color="#0000ff" size=2>=&quot;button2&quot;</font><font color="#ff0000" size=2> Binding=&quot;</font><font color="#0000ff" size=2>{</font><font color="#a31515" size=2>Binding Path=</font><font color="#ff0000" size=2>Resource1</font><font color="#0000ff" size=2>.MainButtonContent}&quot;</font> <font color="#ff0000" size=2>Visibility</font><font color="#0000ff" size=2>=&quot;{Converter={StaticResource <font color="#ff0000">StringToVisibilityConverter</font>}}&quot; /&gt;<br><br>Resources.resx Code:-<br><br><font color="#000000">Name                    Value</font><br>MainButtonVisibility Collapsed <br><br><font color="#000000">The purpose of a converter is to Convert one type into another type based on the desired mapping.<br><br>[ValueConversion( <span class=code-keyword>typeof</span>( <span class=code-keyword>string</span> ), <span class=code-keyword>typeof</span>( Visibility) )]<br><span class=code-keyword>public</span> <span class=code-keyword>class</span> StringToVisibilityConverter: IValueConverter<br>{<br><span class=code-keyword>object</span> IValueConverter.Convert( <br>    <span class=code-keyword>object</span> value, Type targetType, <span class=code-keyword>object</span> parameter, CultureInfo culture )<br>{<br>    string str = (string)value;<br>    if (str==&quot;Collapsed&quot;)<br>        return Visibility.Collapsed;<br>    //Whatever Processing....  <br>} <br><br><span class=code-keyword>object</span> IValueConverter.ConvertBack( <br>    <span class=code-keyword>object</span> value, Type targetType, <span class=code-keyword>object</span> parameter, CultureInfo culture )<br>{<br>  <span class=code-keyword>throw</span> <span class=code-keyword>new</span> NotSupportedException( <span class=code-string>&quot;</span><span class=code-string>ConvertBack not supported.&quot;</span> );<br>}<br>}<br><br>HTH<br><br>Get back if any issues.</font></p></font></font>Sat, 27 Dec 2008 06:47:13 Z2008-12-27T06:47:13Zhttp://social.msdn.microsoft.com/Forums/en-US/vs2010ctpwpfdata/thread/8c72e5de-f597-46bc-b429-59ec73fe830c#7b237294-548a-4f66-b6f6-f1b517358752http://social.msdn.microsoft.com/Forums/en-US/vs2010ctpwpfdata/thread/8c72e5de-f597-46bc-b429-59ec73fe830c#7b237294-548a-4f66-b6f6-f1b517358752KarthikeyanManickamhttp://social.msdn.microsoft.com/Profile/en-US/?user=KarthikeyanManickamHow to set the Visibility of an control from Resources.resx file?<p> Hi Dev,</p> <p>Thanks dude. I have done with my work and I already figured it out the issues.</p> <p>As per the code posted by u, the same way I have tried it was worked properly.</p> <p>The code u have mentioned is the exact answer what I'm looking for.</p> <p> </p> <p>Thank u very much.</p> <p>Karthikeyan Manickam.</p>Mon, 29 Dec 2008 06:16:59 Z2008-12-29T06:16:59Z