Click here to Skip to main content
13,091,300 members (49,176 online)
Rate this:
Please Sign up or sign in to vote.
See more:
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 9:57am
AspDotNetDev 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 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 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
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web02 | 2.8.170813.1 | Last Updated 8 Sep 2011
Copyright © CodeProject, 1999-2017
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