Home Forums WPF controls Xceed Toolkit Plus for WPF DataGrid properties not working on MaterialTabItem

Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • rebeldev
    Participant
    Post count: 7
    #43835 |

    I have a regular WPF DataGrid inside a MaterialTabItem control.

    <Grid Background="Transparent"
           HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
         <xctk:MaterialTabControl Margin="5,5,5,5"
                                  ScrollViewer.VerticalScrollBarVisibility="Auto">
             <xctk:MaterialTabItem Header="Header1">
                 <DataGrid AutoGenerateColumns="False" ItemsSource="{Binding DataCollection}"
                           AlternationCount="2" AlternatingRowBackground="LightYellow"
                           HorizontalGridLinesBrush="LightGray" VerticalGridLinesBrush="LightGray" >
                     <DataGridTextColumn Header="Header2" Binding="{Binding Path=Data1}"/>
                     <DataGridTextColumn Header="Header3" Binding="{Binding Path=Data2}"/>
                 </DataGrid>
             </xctk:MaterialTabItem>
         </xctk:MaterialTabControl>
    </Grid>

    I see the data, but neither of the properties AlternatingRowBackground, HorizontalGridLinesBrush, nor VerticalGridLinesBrush appear, regardless of the colors I use.

    Is there anything I can do to make these properties work? I’m wondering if something in the material controls is overriding these properties.

    Fawzi [Xceed]
    Member
    Post count: 722

    Hi,

    You need to make sure to add the “<DataGrid.Columns>” tag before declaring the “DataGridTextColumn” in order to make the sample compile:

    <Grid Background=”Transparent”
    HorizontalAlignment=”Stretch”
    VerticalAlignment=”Stretch”>
    <xctk:MaterialTabControl Margin=”5,5,5,5″
    ScrollViewer.VerticalScrollBarVisibility=”Auto”>
    <xctk:MaterialTabItem Header=”Header1″>
    <DataGrid AutoGenerateColumns=”False”
    ItemsSource=”{Binding DataCollection}”
    AlternationCount=”2″
    AlternatingRowBackground=”Orange”
    HorizontalGridLinesBrush=”Green”
    VerticalGridLinesBrush=”Blue”>
    <DataGrid.Columns>
    <DataGridTextColumn Header=”Header2″
    Binding=”{Binding Path=Data1}” />
    <DataGridTextColumn Header=”Header3″
    Binding=”{Binding Path=Data2}” />
    </DataGrid.Columns>
    </DataGrid>
    </xctk:MaterialTabItem>
    </xctk:MaterialTabControl>
    </Grid>

    When trying this sample with Toolkit v3.0, under Windows10, I can see the colors of the alternatingRowBackground as well as the colors for HorizontalGridLines and VerticalGrdiLines.

    Are you using a different Windows or Toolkit version?

    rebeldev
    Participant
    Post count: 7

    I apologize. I did have the DataGrid.Columns tags in my code; I just forgot to type them in my forum submission.

    I am using toolkit version 2.9 on Windows 7, Service Pack 1. My workgroup operates with the same toolkit version, and we simply haven’t upgraded to version 3.0, but that may happen soon. It is unknown when the operating system will be upgraded to Windows 10.

    It appears that the only difference between the code in your reply and my working code is the colors. I changed my colors to your suggested colors, but the outcome was the same — no alternating colors and no grid lines.

    I noticed that if I take away all the DataGrid columns and leave just the DataGrid.Columns tags, I see the alternating rows, but not the grid lines. Adding an empty DataGridTextColumn causes the alternating rows to appear, except for a thin strip on the left-hand side.

    To clarify, here is the code I am using:

    <Grid Background="Transparent"
           HorizontalAlignment="Stretch" VerticalAlignment="Stretch">
         <xctk:MaterialTabControl Margin="5,5,5,5"
                                  ScrollViewer.VerticalScrollBarVisibility="Auto">
             <xctk:MaterialTabItem Header="Header1">
                 <DataGrid AutoGenerateColumns="False" ItemsSource="{Binding DataCollection}"
                           AlternationCount="2" AlternatingRowBackground="LightYellow"
                           HorizontalGridLinesBrush="LightGray" VerticalGridLinesBrush="LightGray" >
                     <DataGrid.Columns>
                         <DataGridTextColumn Header="Header2" Binding="{Binding Path=Data1}"/>
                         <DataGridTextColumn Header="Header3" Binding="{Binding Path=Data2}"/>
                     </DataGrid.Columns>
                 </DataGrid>
             </xctk:MaterialTabItem>
         </xctk:MaterialTabControl>
    </Grid>

    Thank you.

    Fawzi [Xceed]
    Member
    Post count: 722

    Hi,

    Unfortunately, we were not able to reproduce the issue using your code snippet. Are you experiencing the same issue when the DataGrid is outside a MaterialTabItem/MaterialTabControl? Could you send me a simple stand alone sample project which reproduces the issue so that I could have a closer look. You may send it to: support@xceed.com

    rebeldev
    Participant
    Post count: 7

    I don’t believe I can send a small project at this time. I’m sorry.

    After further investigation, it appears that a theme is being applied as far up the visual tree as the AvalonDock within which my entire view sits; I believe it is a Metro theme. Referring to my example, I set the background for the DataGrid, MaterialTabItem, MaterialTabControl, Grid, and even the UserControl at the head of the xaml file to different colors. No change.

    I’m guessing I need to override the theme somehow. Is there a way to do that?

Viewing 5 posts - 1 through 5 (of 5 total)
  • You must be logged in to reply to this topic.