question

Butachan-5023 avatar image
0 Votes"
Butachan-5023 asked Butachan-5023 answered

Group framework elements to apply property

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

dotnet-wpf-xaml
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

HuiLiu-MSFT avatar image
0 Votes"
HuiLiu-MSFT answered HuiLiu-MSFT commented

Hi,@Butachan-5023.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.




visibility.txt (2.9 KiB)
image.png (7.1 KiB)
image.png (9.4 KiB)
image.png (8.2 KiB)
· 3
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

@Butachan-5023 . Did my answer solve your problem? If so, you could accept it as the answer. It's helpful for community members with related questions.

0 Votes 0 ·

Hi thanks for the answer!
Sorry mate! I adapted your code to my project first. Didn't work

Then I literally copy paste your code in another project. Nothing happens on click

0 Votes 0 ·

Hi, @Butachan-5023 . Could you show me the complete sample code of your project to analyze?

0 Votes 0 ·
Butachan-5023 avatar image
0 Votes"
Butachan-5023 answered

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

5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.