开发者

WPF Datagrid/Listview INVERTED?

开发者 https://www.devze.com 2023-04-11 03:03 出处:网络
Is Possible to get a datagrid (or listview) control inverted? For example, usually we have a listview like this:

Is Possible to get a datagrid (or listview) control inverted? For example, usually we have a listview like this:

Name Age Job

John 23 eng

Now I want to invert the table:

Label 1col

Name John

Age 23

Job eng

Thu开发者_高级运维s we can able to select the single column...


Current WPF DataGrid dioes not perform this straight away...

But there are options...

XML Way

XML format of data can help you to achieve this.

e.g

        <Employees>
            <Employee>
               <FirstName>A</FirstName>
               <LastName>B</LastName>
            </Employee>
            <Employee>
               <FirstName>C</FirstName>
               <LastName>D</LastName>
            </Employee>
            <Employee>
               <FirstName>P</FirstName>
               <LastName>Q</LastName>
            </Employee>
        </Employees>

needs to be transformed using an XSLT that converts it into something like this...

        <Columns>
           <Column Name="FirstName">
               <Employee>A</Employee>
               <Employee>C</Employee>
               <Employee>P</Employee>
           </Column>
           <Column Name="LastName">
               <Employee>B</Employee>
               <Employee>D</Employee>
               <Employee>Q</Employee>
           </Column>
        </Columns>

The column headers has to be overriden by styles that hide the column header names when transformation takes place.

Also RowHeader has to be styled to "steal" names /Column@Name in the same order as they appear in the data.

Rotate Transform Way

Roate the data grid in 90 degreess and each cell content in 270 degrees. Dont know if Layout or Render transform gives better results...

Let me know if this guides you in correct direction.


In google I find this fantastic solution:

http://blogs.microsoft.co.il/blogs/tomershamam/archive/2008/09/22/lt-howto-gt-replace-listview-columns-with-rows-lt-howto-gt.aspx

0

精彩评论

暂无评论...
验证码 换一张
取 消