Click here to Skip to main content
12,510,985 members (58,481 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB WPF VB.NET
Hello,
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


<listview>
     <listview.view>
       <gridviewcolumn header="Code " width="50">
          <gridviewcolumn.celltemplate>
              <datatemplate>
                    <textblock text="{Binding Path=Code}" textalignment="Center" />
               </datatemplate>
          </gridviewcolumn.celltemplate>
       </gridviewcolumn> 
 
        <gridviewcolumn header="" width="20">
            <gridviewcolumn.celltemplate>
               <datatemplate>
                   <textblock text="{Binding Path=CodeType}" textalignment="Center" />
                                                   
                                    </datatemplate>
                                </gridviewcolumn.celltemplate>
                            </gridviewcolumn>
</listview.view>
</listview>
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
2-Liquid
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
Tom9748128
Comments
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 | Mobile
Web02 | 2.8.160929.1 | Last Updated 8 Sep 2011
Copyright © CodeProject, 1999-2016
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