.net - Displaying controls based on radio button selected -


I have three radio buttons based on the selection of radio buttons, I have one of three controls - one text box, one Dropdown list, or want to disorient a button. How do I show control on the basis of a selected radio button?

Visibility after

You can force control of the RadioButton for IsChecked property, using BooleanToVisibilityConverter :

  & lt; Page xmlns = "http://schemas.microsoft.com/winfx/2006/Xaml/Presentation" xmlns: x = "http://schemas.microsoft.com/winfx/2006/xaml" & gt; & Lt; Page.Resources & gt; & Lt; BooleanToVisibilityConverter x: key = "convvisibility" /> & Lt; /Page.Resources> & Lt; Grid & gt; & Lt; StackPanel Orientation = "Vertical" & gt; & Lt; Radio Button Name = "Radiobutton 1" GroupName = "Group 1" & gt; Control 1 & lt; / Radio button & gt; & Lt; Radio button name = "radio button 2" groupname = "group 1" & gt; Control 2 & lt; / Radio button & gt; & Lt; Radio button name = "radio button 3" group name = "group 1" & gt; Control 3 & lt; / Radio button & gt; & Lt; Grid & gt; & Lt; Button visibility = "{Isichecked, ElementName = radioButton1, converter = {StaticResource convVisibility}}" & gt; 1 button & lt; / Button & gt; & Lt; TextBox Visibility = "{Binding ischek, Element name = Radio button 2, converter = {static resource conquency}}" & gt; 2 TextBlock & lt; / TextBlock & gt; & Lt; Text box visibility = "{Isichecked Binding, ElementName = radioButton3, converter = {StaticResource convVisibility}}" & gt; 3 text boxes & lt; / Text box & gt; & Lt; / Grid & gt; & Lt; / StackPanel & gt; & Lt; / Grid & gt; & Lt; / Page & gt;  

Edit:

This solution works great and it is easy to implement it anyways I can prevent it from being hidden in design mode Is control?

I do not know about other designers (for example mix), but the visual studio designer is never in control ...

However, you can apply your own converter, which will always be visible in design mode. The BooleanTuVibility Converter class has been closed for some vague reasons, so you can not inherit it. You can, instead of transferring the conversion to a BooleanToVisibilityConverter, if you do not want to rewrite the conversion logic: Public class MyBooleanToVisibilityConverter: {Personal BooleanToVisibilityConverter _converter = New BooleanToVisibilityConverter (); Private dependency object _dummy = new dependency object (); Private Bull DesignMode {Get {Designer Properties} Get IS Insignificant (_dummy); }} #region IValueConverter Member Public Object Convert (Object Value, Type TargetType, Object Parameter, System.Globalization.CultureInfo Culture) {If (DesignMode) Visibility.Visible return; And return _converter.Convert (value, target type, parameter, culture); } Public Object ConvertBack (Object Value, Type TargetType, Object Parameter, System.Globalization.CultureInfo Culture) {Return _converter.ConvertBack (Value, TargetType, Parameter, Culture); } #endregion}


Comments

Popular posts from this blog

c++ - Linux and clipboard -

What is expire header and how to achive them in ASP.NET and PHP? -

sql server - How can I determine which of my SQL 2005 statistics are unused? -