Home Forums WPF controls Xceed DataGrid for WPF GroupByControl

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • User (Old forums)
    Member
    Post count: 23064
    #21867 |

    I cant seem to style the GroupByContol control. Can anyone show a simple example of chaging the Background color of the box and the text in it? I have looked through the documentation but no luck yet.

    Any information would be greatly appreciated.

    offroadn

    Imported from legacy forums. Posted by keith (had 6366 views)

    Xceed Support
    Member
    Post count: 5658

    To change the text within the GroupByControl, you can affect the NoGroupContent property either by style or directly in the DataTemplate for the Header.

    For the Background color of the GroupByControl, depending on the Theme you use, it would be slightly different:

    – For all themes but Aero: You can set the Background property by style or directly in the DataTemplate.

    – For the Aero theme, you would need to change the template of the ControlTemplate for the GroupByControl… You can start from the resource named “aeroNormalColorGroupByControlTemplate” in the file “Aero.normalcolor.Resources.xaml” located in the Xceed Components installation directory under “Xceed DataGrid for WPF 1.0\Themes\Aero\Resources”

    See next post for some sample code.

    Imported from legacy forums. Posted by Marcus [Xceed] (had 632 views)

    Xceed Support
    Member
    Post count: 5658

    Example 1: doing it directly on the Header Template

    <code>
    <xcdg:DataGridControl.View>
    <xcdg:TableView>
    <xcdg:TableView.FixedHeaders>
    <xcdg:ClearHeadersFooters/>

    <DataTemplate>
    <xcdg:GroupByControl NoGroupContent=”My Own Custom Text” Background=”HotPink” Template={StaticResource myOwnControlTemplate}/>
    <!– You can do either play with the background (any theme but aero) or the template (aero) or both (if your custom control template does some TemplateBinding to the background) –>
    </DataTemplate>

    </xcdg:TableView.FixedHeaders>
    </xcdg:TableView>
    </xcdg:DataGridControl.View>

    </code>

    Example 2: Doing it by an implicit style

    <code>
    <Page.Resources>
    <Style TargetType=”{x:Type xcdg:GroupByControl}”>
    <Setter Property=”NoGroupContent” Value=”My Own Custom Text”/>

    <Setter Property=”Background” Value=”HotPink” />
    <!– You can do either the above (any theme but aero) or below (aero) or both (if your custom control template does some TemplateBinding to the background) –>
    <Setter Property=”Template” Value=”{StaticResource myOwnControlTemplate}”/>
    </Style>
    </Page.Resource>
    </code>

    Imported from legacy forums. Posted by Marcus [Xceed] (had 814 views)

    User (Old forums)
    Member
    Post count: 23064

    I tried the following but the background does not change. If I change background to forground then that works. Is there a bug with the use of background?

    <DataTemplate>
    <xcdg:GroupByControl NoGroupContent=”My Own Custom Text” Background=”Yellow” />
    </DataTemplate>

    Imported from legacy forums. Posted by keith (had 414 views)

    User (Old forums)
    Member
    Post count: 23064

    What Theme is the DataGrid being displayed with?

    Imported from legacy forums. Posted by Pascal (had 352 views)

    User (Old forums)
    Member
    Post count: 23064

    OK – its not a problem when I am not using Aero. I dont see the path that you suggested in one of the previous posts up above. We are developing on Vista with Aero and this will be a concern.

    In my Resource area I am setting a style for GroupByControl and placing a setter value for Template. What control should be used in the ControlTemplate in order to apply the background color?

    Imported from legacy forums. Posted by keith (had 353 views)

    User (Old forums)
    Member
    Post count: 23064

    The package should have installed the source code for all our Themes… If you don’t see this file:

    C:\Program Files\Xceed Components\Xceed DataGrid for WPF 1.0\Themes\Aero\Resources\Aero.normalcolor.Resources.xaml

    Could you please try running the setup program again and selecting the “repair” option?

    Imported from legacy forums. Posted by Pascal (had 296 views)

    User (Old forums)
    Member
    Post count: 23064

    This is for others to reference. I was able to style the column headings and also the groupbycontrol along with the groupbyitems with the following code…

    <!–This styles the top part of the grid where columns are dropped –>
    <Style x:Key=”{x:Type xcdg:GroupByControl}” TargetType=”xcdg:GroupByControl”>
    <Setter Property=”OverridesDefaultStyle” Value=”True” />
    <Setter Property=”SnapsToDevicePixels” Value=”True” />
    <Setter Property=”Template”>
    <Setter.Value>
    <ControlTemplate TargetType=”xcdg:GroupByControl”>
    <Border Name=”Border” MinHeight=”27″ Background=”LightSkyBlue” BorderBrush=”SkyBlue” BorderThickness=”.5″>
    <ItemsPresenter/>
    </Border>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    </Style>
    <Style x:Key=”{x:Type xcdg:GroupByItem}” TargetType=”xcdg:GroupByItem” >
    <Setter Property=”OverridesDefaultStyle” Value=”True” />
    <Setter Property=”SnapsToDevicePixels” Value=”True” />
    <Setter Property=”Template”>
    <Setter.Value>
    <ControlTemplate TargetType=”xcdg:GroupByItem”>
    <Grid Background=”LightSkyBlue” Height=”30″>
    <Border Width=”100″>
    <Border.Background>
    <RadialGradientBrush >
    <GradientStop Color=”#FF000000″ Offset=”0″/>
    <GradientStop Color=”LightSkyBlue” Offset=”0.9″/>
    </RadialGradientBrush>
    </Border.Background>
    <Border.BorderBrush>
    <LinearGradientBrush EndPoint=”1,0.5″ StartPoint=”0,0.5″>
    <GradientStop Color=”#FF000000″ Offset=”0″/>
    <GradientStop Color=”#FFEEC65C” Offset=”1″/>
    </LinearGradientBrush>
    </Border.BorderBrush>
    </Border>
    <ContentPresenter HorizontalAlignment=”Center” VerticalAlignment=”Center”>
    </ContentPresenter>
    </Grid>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    <Setter Property=”Foreground”>
    <Setter.Value>
    <SolidColorBrush Color=”White”/>
    </Setter.Value>
    </Setter>
    </Style>
    <!–this styles the column headers –>
    <Style TargetType=”{x:Type xcdg:ColumnManagerCell}”>
    <Setter Property=”Template”>
    <Setter.Value>
    <ControlTemplate TargetType=”xcdg:ColumnManagerCell”>
    <Grid Background=”LightSkyBlue” Height=”30″>
    <Border Width=”100″>
    <Border.Background>
    <RadialGradientBrush >
    <GradientStop Color=”#FF000000″ Offset=”0″/>
    <GradientStop Color=”LightSkyBlue” Offset=”0.9″/>
    </RadialGradientBrush>
    </Border.Background>
    <Border.BorderBrush>
    <LinearGradientBrush EndPoint=”1,0.5″ StartPoint=”0,0.5″>
    <GradientStop Color=”#FF000000″ Offset=”0″/>
    <GradientStop Color=”#FFEEC65C” Offset=”1″/>
    </LinearGradientBrush>
    </Border.BorderBrush>
    </Border>
    <ContentPresenter HorizontalAlignment=”Center” VerticalAlignment=”Center”>
    </ContentPresenter>
    </Grid>
    </ControlTemplate>
    </Setter.Value>
    </Setter>
    <Setter Property=”Foreground”>
    <Setter.Value>
    <SolidColorBrush Color=”White”/>
    </Setter.Value>
    </Setter>
    </Style>

    Imported from legacy forums. Posted by keith (had 6926 views)

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