Click here to Skip to main content
Rate this: bad
Please Sign up or sign in to vote.
See more: WPF VB.NET
I'm a newbie to WPF and having troubles to figure out how to hide or show a column based on its data

I currently have a list view as

       <gridviewcolumn header="Code " width="50">
                    <textblock text="{Binding Path=Code}" textalignment="Center" />
        <gridviewcolumn header="" width="20">
                   <textblock text="{Binding Path=CodeType}" textalignment="Center" />
I tried not to display the CodeType column when the data in the column is U and show it when data is S after I dynamically changed to datasource (ListView.dataContext = ds.Tables(0) .....ete)
for ex: my listview could show like:

Code CodeType
1-Empty S
3-Rock S

the 2-Liquid has code type of U and not show U here.

Read lots of article here but still having errors and could not complete it.
Please let me know if you have an answer. Thanks a lot.
Posted 8-Sep-11 10:57am
AspDotNetDev at 8-Sep-11 16:09pm
Sounds like you want a DataTrigger. You can set a Visibility property to Hidden when the data is set to some particular value. Update your question if you need help with that (Google should provide sufficient guidance).
dasblinkenlight at 8-Sep-11 17:05pm
The question does not make much sense to me: you refer to a "value of a column" as if it were singular, yet there may be many values in a column. A list view column holds potentially distinct values in each of its rows. Which of these many values would you like your code to use when making a decision to hide the column? Please edit your question to provide more clarity.
AspDotNetDev at 9-Sep-11 14:40pm
I think the OP means "field", not "column" (as demonstrated by the sample output).

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
0 /\jmot 200
1 Zoltán Zörgő 175
2 Richard Deeming 170
3 Peter Leow 150
4 Sergey Alexandrovich Kryukov 150
0 Sergey Alexandrovich Kryukov 9,328
1 OriginalGriff 6,831
2 Peter Leow 4,477
3 Zoltán Zörgő 3,984
4 Richard MacCutchan 2,832

Advertise | Privacy | Mobile
Web01 | 2.8.150129.1 | Last Updated 8 Sep 2011
Copyright © CodeProject, 1999-2015
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100