Group framework elements to apply property

Butachan 21 Reputation points
2022-11-09T16:49:44.463+00:00

Hi, I have many textbox that I want to control (change visibility) programmaticaly.
But I can not find a good way to do it.
So for now my cs contains this outrageous code:

                     lab_code.Visibility = Visibility.Visible;  
                    lab_destinataire.Visibility = Visibility.Visible;  
                    Form_code.Visibility = Visibility.Visible;  
                    Form_destinataire.Visibility = Visibility.Visible;  
                    Titre_clients.Visibility = Visibility.Visible;  
                    lab_traffic.Visibility = Visibility.Visible;  
                    Form_trafic.Visibility = Visibility.Visible;  
                    Form_bgpcli.Visibility = Visibility.Visible;  
                     lab_plat.Visibility = Visibility.Collapsed;  
                    Form_plateforme.Visibility = Visibility.Collapsed;  

I'd like to put them together (like giving the same css class name) then change their property pls

XAML
XAML
A language based on Extensible Markup Language (XML) that enables developers to specify a hierarchy of objects with a set of properties and logic.
778 questions
0 comments No comments
{count} votes

2 answers

Sort by: Most helpful
  1. Hui Liu-MSFT 47,101 Reputation points Microsoft Vendor
    2022-11-10T06:22:41.307+00:00

    Hi,@Butachan .Welcome Microsoft Q&A.
    You could bind the first 8 text boxes to property MyVisibility and the last two text boxes to property MyVisibility1 . Here is sample code

    complete code:

    258985-visibility.txt

    The result:
    designer screenshot.

    258986-image.png
    screenshot of initial value.

    258996-image.png

    Screenshot of the modified value.

    259032-image.png

    ----------------------------------------------------------------------------

    If the response is helpful, please click "Accept Answer" and upvote it.
    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


  2. Butachan 21 Reputation points
    2022-11-17T18:18:26.997+00:00

    I finally used ohter methods that are easier but less adjustable

    1) wrap the elements in a grid

    2) use a foreach( control texb in ...)

    Thanks

    0 comments No comments