This is a migrated thread and some comments may be shown as answers.

Styles from Resource Dictionary for RadGridView

3 Answers 180 Views
GridView
This is a migrated thread and some comments may be shown as answers.
Pallavi
Top achievements
Rank 1
Pallavi asked on 31 Oct 2013, 07:38 AM
Dear Support,

I have defined some styles for the RadGridView in my global resource dictionary. why it does not automatically applied to controls, why i must set it explicitly? for example i have defined style for column headers but i must specify it as HeaderCellStyle for every column. 
Is there any way to define style in resources and applied it automatically  without specifying it?

Thanks
Pallavi.

3 Answers, 1 is accepted

Sort by
0
Vanya Pavlova
Telerik team
answered on 31 Oct 2013, 09:11 AM
Hello Pallavi,

 

Generally implicit styles should be handled correspondingly for all parts of RadGridView.
Would it be possible to be a bit more specific?
Do you use standard binaries or NoXAML ones?
Do you apply a theme different than the default one (Office_Black) ?
It could be great if you can share small sample demo, which illustrates your exact scenario.
You may send it to us as an attachment in a new support thread.

 

Regards,
Vanya Pavlova
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
0
Pallavi
Top achievements
Rank 1
answered on 31 Oct 2013, 09:21 AM
Here is my style defined for GridViewHeaderCell i have defined this style in resource dictionary at application level.
 
<Style TargetType="{x:Type telerik:GridViewHeaderCell}" x:Key="TelerikGridColumnHeaderStyle"><br>        <Setter Property="Template" Value="{DynamicResource GridViewHeaderCellControlTemplate1}"></Setter><br>        <Setter Property="Background" Value="{DynamicResource ControlBackgroundDark}"></Setter><br>        <Setter Property="BorderBrush" Value="BlueViolet"></Setter><br>        <Setter Property="VerticalContentAlignment" Value="Center"></Setter><br>        <Setter Property="HorizontalContentAlignment" Value="Center"></Setter><br>       <br>    </Style><br>    <ControlTemplate x:Key="GridViewHeaderCellControlTemplate1" TargetType="{x:Type telerik:GridViewHeaderCell}"><br>    <span class="Apple-tab-span" style="white-space:pre">    </span><Grid x:Name="PART_OuterGrid"><br>    <span class="Apple-tab-span" style="white-space:pre">      </span><Grid.RowDefinitions><br>    <span class="Apple-tab-span" style="white-space:pre">           </span><RowDefinition Height="*"/><br>    <span class="Apple-tab-span" style="white-space:pre">         </span><RowDefinition Height="*"/><br>    <span class="Apple-tab-span" style="white-space:pre">     </span></Grid.RowDefinitions><br>    <span class="Apple-tab-span" style="white-space:pre">      </span><VisualStateManager.VisualStateGroups><br>    <span class="Apple-tab-span" style="white-space:pre">          </span><VisualStateGroup x:Name="CommonStates"><br>    <span class="Apple-tab-span" style="white-space:pre">                </span><VisualState x:Name="Normal"/><br>    <span class="Apple-tab-span" style="white-space:pre">              </span><VisualState x:Name="MouseOver"><br>    <span class="Apple-tab-span" style="white-space:pre">                    </span><Storyboard><br>    <span class="Apple-tab-span" style="white-space:pre">                        </span><ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="GridViewHeaderCell_Over"><br>    <span class="Apple-tab-span" style="white-space:pre">                          </span><DiscreteObjectKeyFrame KeyTime="0"><br>    <span class="Apple-tab-span" style="white-space:pre">                                </span><DiscreteObjectKeyFrame.Value><br>    <span class="Apple-tab-span" style="white-space:pre">                                  </span><Visibility>Visible</Visibility><br>    <span class="Apple-tab-span" style="white-space:pre">                              </span></DiscreteObjectKeyFrame.Value><br>    <span class="Apple-tab-span" style="white-space:pre">                         </span></DiscreteObjectKeyFrame><br>    <span class="Apple-tab-span" style="white-space:pre">                       </span></ObjectAnimationUsingKeyFrames><br>    <span class="Apple-tab-span" style="white-space:pre">                    </span></Storyboard><br>    <span class="Apple-tab-span" style="white-space:pre">               </span></VisualState><br>    <span class="Apple-tab-span" style="white-space:pre">              </span><VisualState x:Name="Ascending"><br>    <span class="Apple-tab-span" style="white-space:pre">                    </span><Storyboard><br>    <span class="Apple-tab-span" style="white-space:pre">                        </span><ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Foreground" Storyboard.TargetName="ContentPresenter"><br>    <span class="Apple-tab-span" style="white-space:pre">                         </span><DiscreteObjectKeyFrame KeyTime="0" Value="{DynamicResource ExpanderForeground}"/><br>    <span class="Apple-tab-span" style="white-space:pre">                      </span></ObjectAnimationUsingKeyFrames><br>    <span class="Apple-tab-span" style="white-space:pre">                        </span><DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_SortIndicator"><br>    <span class="Apple-tab-span" style="white-space:pre">                          </span><DiscreteDoubleKeyFrame KeyTime="0" Value="1"/><br>    <span class="Apple-tab-span" style="white-space:pre">                     </span></DoubleAnimationUsingKeyFrames><br>    <span class="Apple-tab-span" style="white-space:pre">                        </span><ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="GridViewHeaderCell_Selected"><br>    <span class="Apple-tab-span" style="white-space:pre">                          </span><DiscreteObjectKeyFrame KeyTime="0"><br>    <span class="Apple-tab-span" style="white-space:pre">                                </span><DiscreteObjectKeyFrame.Value><br>    <span class="Apple-tab-span" style="white-space:pre">                                  </span><Visibility>Visible</Visibility><br>    <span class="Apple-tab-span" style="white-space:pre">                              </span></DiscreteObjectKeyFrame.Value><br>    <span class="Apple-tab-span" style="white-space:pre">                         </span></DiscreteObjectKeyFrame><br>    <span class="Apple-tab-span" style="white-space:pre">                       </span></ObjectAnimationUsingKeyFrames><br>    <span class="Apple-tab-span" style="white-space:pre">                    </span></Storyboard><br>    <span class="Apple-tab-span" style="white-space:pre">               </span></VisualState><br>    <span class="Apple-tab-span" style="white-space:pre">              </span><VisualState x:Name="Descending"><br>    <span class="Apple-tab-span" style="white-space:pre">                   </span><Storyboard><br>    <span class="Apple-tab-span" style="white-space:pre">                        </span><DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="Opacity" Storyboard.TargetName="PART_SortIndicator"><br>    <span class="Apple-tab-span" style="white-space:pre">                          </span><DiscreteDoubleKeyFrame KeyTime="0" Value="1"/><br>    <span class="Apple-tab-span" style="white-space:pre">                     </span></DoubleAnimationUsingKeyFrames><br>    <span class="Apple-tab-span" style="white-space:pre">                        </span><DoubleAnimationUsingKeyFrames Storyboard.TargetProperty="(UIElement.RenderTransform).(TransformGroup.Children)[2].(RotateTransform.Angle)" Storyboard.TargetName="PART_SortIndicator"><br>    <span class="Apple-tab-span" style="white-space:pre">                         </span><EasingDoubleKeyFrame KeyTime="0" Value="180"/><br>    <span class="Apple-tab-span" style="white-space:pre">                     </span></DoubleAnimationUsingKeyFrames><br>    <span class="Apple-tab-span" style="white-space:pre">                        </span><ObjectAnimationUsingKeyFrames Storyboard.TargetProperty="Visibility" Storyboard.TargetName="GridViewHeaderCell_Selected"><br>    <span class="Apple-tab-span" style="white-space:pre">                          </span><DiscreteObjectKeyFrame KeyTime="0"><br>    <span class="Apple-tab-span" style="white-space:pre">                                </span><DiscreteObjectKeyFrame.Value><br>    <span class="Apple-tab-span" style="white-space:pre">                                  </span><Visibility>Visible</Visibility><br>    <span class="Apple-tab-span" style="white-space:pre">                              </span></DiscreteObjectKeyFrame.Value><br>    <span class="Apple-tab-span" style="white-space:pre">                         </span></DiscreteObjectKeyFrame><br>    <span class="Apple-tab-span" style="white-space:pre">                       </span></ObjectAnimationUsingKeyFrames><br>    <span class="Apple-tab-span" style="white-space:pre">                    </span></Storyboard><br>    <span class="Apple-tab-span" style="white-space:pre">               </span></VisualState><br>    <span class="Apple-tab-span" style="white-space:pre">          </span></VisualStateGroup><br>    <span class="Apple-tab-span" style="white-space:pre">     </span></VisualStateManager.VisualStateGroups><br>    <span class="Apple-tab-span" style="white-space:pre">     </span><Border BorderBrush="BlueViolet" BorderThickness="0"><br>    <span class="Apple-tab-span" style="white-space:pre">           </span><Grid x:Name="PART_HeaderCellGrid"><br>    <span class="Apple-tab-span" style="white-space:pre">             </span><Grid.ColumnDefinitions><br>    <span class="Apple-tab-span" style="white-space:pre">                    </span><ColumnDefinition Width="*"/><br>    <span class="Apple-tab-span" style="white-space:pre">                   </span><ColumnDefinition Width="Auto"/><br>    <span class="Apple-tab-span" style="white-space:pre">                    </span><ColumnDefinition Width="Auto"/><br>    <span class="Apple-tab-span" style="white-space:pre">                </span></Grid.ColumnDefinitions><br>    <span class="Apple-tab-span" style="white-space:pre">               </span><Border x:Name="GridViewHeaderCell" Background="{TemplateBinding Background}" Grid.ColumnSpan="2" Margin="1,0,1,1"/><br>    <span class="Apple-tab-span" style="white-space:pre">                </span><Border x:Name="GridViewHeaderCell_Over" BorderBrush="Transparent" Background="{DynamicResource MouseOverBrush}" Grid.ColumnSpan="2" Opacity="0.1" Visibility="Collapsed"/><br>    <span class="Apple-tab-span" style="white-space:pre">             </span><Border x:Name="GridViewHeaderCell_Selected" BorderBrush="Transparent" Background="{DynamicResource SelectedBackgroundBrush}" Grid.ColumnSpan="2" Margin="0,0,0,1" Visibility="Collapsed"/><br>    <span class="Apple-tab-span" style="white-space:pre">             </span><ContentControl x:Name="ContentPresenter" ContentTemplate="{TemplateBinding ContentTemplate}" Content="{TemplateBinding Content}" Grid.Column="0" Foreground="{TemplateBinding Foreground}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" IsTabStop="{TemplateBinding IsTabStop}" Margin="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"><br>    <span class="Apple-tab-span" style="white-space:pre">                   </span><ContentControl.Style><br>    <span class="Apple-tab-span" style="white-space:pre">                      </span><Style TargetType="{x:Type ContentControl}"><br>    <span class="Apple-tab-span" style="white-space:pre">                            </span><Setter Property="HorizontalContentAlignment" Value="Center"/><br>    <span class="Apple-tab-span" style="white-space:pre">                          </span><Setter Property="VerticalContentAlignment" Value="Center"/><br>    <span class="Apple-tab-span" style="white-space:pre">                        </span></Style><br>    <span class="Apple-tab-span" style="white-space:pre">                    </span></ContentControl.Style><br>    <span class="Apple-tab-span" style="white-space:pre">             </span></ContentControl><br>    <span class="Apple-tab-span" style="white-space:pre">               </span><Path x:Name="PART_SortIndicator" Data="M10.000001,0L20.000002,20 2.3395899E-08,20z" Fill="{DynamicResource GlyphBrush}" HorizontalAlignment="Center" Height="4" Margin="0,2,0,0" Opacity="0" RenderTransformOrigin="0.5,0.5" Stretch="Fill" VerticalAlignment="Top" Width="4"><br>    <span class="Apple-tab-span" style="white-space:pre">                 </span><Path.RenderTransform><br>    <span class="Apple-tab-span" style="white-space:pre">                      </span><TransformGroup><br>    <span class="Apple-tab-span" style="white-space:pre">                            </span><ScaleTransform/><br>    <span class="Apple-tab-span" style="white-space:pre">                           </span><SkewTransform/><br>    <span class="Apple-tab-span" style="white-space:pre">                            </span><RotateTransform/><br>    <span class="Apple-tab-span" style="white-space:pre">                          </span><TranslateTransform/><br>    <span class="Apple-tab-span" style="white-space:pre">                       </span></TransformGroup><br>    <span class="Apple-tab-span" style="white-space:pre">                   </span></Path.RenderTransform><br>    <span class="Apple-tab-span" style="white-space:pre">             </span></Path><br>    <span class="Apple-tab-span" style="white-space:pre">             </span><ContentControl Foreground="{DynamicResource ExpanderForeground}" FontSize="7" HorizontalAlignment="Center" IsTabStop="{TemplateBinding IsTabStop}" Margin="14,-1,0,0" VerticalAlignment="Top"><br>    <span class="Apple-tab-span" style="white-space:pre">                 </span><ContentControl.Visibility><br>    <span class="Apple-tab-span" style="white-space:pre">                     </span><Binding Path="SortingIndex" RelativeSource="{RelativeSource TemplatedParent}"><br>    <span class="Apple-tab-span" style="white-space:pre">                         </span><Binding.Converter><br>    <span class="Apple-tab-span" style="white-space:pre">                             </span><telerik:SortingIndexToVisibilityConverter/><br>    <span class="Apple-tab-span" style="white-space:pre">                            </span></Binding.Converter><br>    <span class="Apple-tab-span" style="white-space:pre">                        </span></Binding><br>    <span class="Apple-tab-span" style="white-space:pre">                  </span></ContentControl.Visibility><br>    <span class="Apple-tab-span" style="white-space:pre">                    </span><Binding Path="SortingIndex" RelativeSource="{RelativeSource TemplatedParent}"><br>    <span class="Apple-tab-span" style="white-space:pre">                     </span><Binding.Converter><br>    <span class="Apple-tab-span" style="white-space:pre">                         </span><telerik:SortingIndexConverter/><br>    <span class="Apple-tab-span" style="white-space:pre">                        </span></Binding.Converter><br>    <span class="Apple-tab-span" style="white-space:pre">                    </span></Binding><br>    <span class="Apple-tab-span" style="white-space:pre">              </span></ContentControl><br>    <span class="Apple-tab-span" style="white-space:pre">               </span><telerik:FilteringDropDown x:Name="PART_DistinctFilterControl" Grid.Column="1" IsTabStop="False" Margin="0,0,-2,0" Visibility="{TemplateBinding FilteringUIVisibility}"/><br>    <span class="Apple-tab-span" style="white-space:pre">               </span><Thumb x:Name="PART_LeftHeaderGripper" MouseEnter="MouseEnter" MouseLeave="SplitterMouseLeave" Grid.ColumnSpan="2" HorizontalAlignment="Left" IsTabStop="{TemplateBinding IsTabStop}"><br>    <span class="Apple-tab-span" style="white-space:pre">                  </span><Thumb.Style><br>    <span class="Apple-tab-span" style="white-space:pre">                       </span><Style TargetType="{x:Type Thumb}"><br>    <span class="Apple-tab-span" style="white-space:pre">                         </span><Setter Property="Width" Value="6"/><br>    <span class="Apple-tab-span" style="white-space:pre">                            </span><Setter Property="Background" Value="Transparent"/><br>    <span class="Apple-tab-span" style="white-space:pre">                         </span><Setter Property="BorderBrush" Value="Transparent"/><br>    <span class="Apple-tab-span" style="white-space:pre">                            </span><Setter Property="BorderThickness" Value="0"/><br>    <span class="Apple-tab-span" style="white-space:pre">                          </span><Setter Property="HorizontalContentAlignment" Value="Stretch"/><br>    <span class="Apple-tab-span" style="white-space:pre">                         </span><Setter Property="VerticalContentAlignment" Value="Stretch"/><br>    <span class="Apple-tab-span" style="white-space:pre">                           </span><Setter Property="Padding" Value="0"/><br>    <span class="Apple-tab-span" style="white-space:pre">                          </span><Setter Property="Cursor" Value="SizeWE"/><br>    <span class="Apple-tab-span" style="white-space:pre">                          </span><Setter Property="Template"><br>    <span class="Apple-tab-span" style="white-space:pre">                                </span><Setter.Value><br>    <span class="Apple-tab-span" style="white-space:pre">                                  </span><ControlTemplate TargetType="{x:Type Thumb}"><br>    <span class="Apple-tab-span" style="white-space:pre">                                       </span><Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/><br>    <span class="Apple-tab-span" style="white-space:pre">                                   </span></ControlTemplate><br>    <span class="Apple-tab-span" style="white-space:pre">                              </span></Setter.Value><br>    <span class="Apple-tab-span" style="white-space:pre">                         </span></Setter><br>    <span class="Apple-tab-span" style="white-space:pre">                       </span></Style><br>    <span class="Apple-tab-span" style="white-space:pre">                    </span></Thumb.Style><br>    <span class="Apple-tab-span" style="white-space:pre">              </span></Thumb><br>                    <Thumb x:Name="PART_RightHeaderGripper" MouseEnter="MouseEnter" MouseLeave="SplitterMouseLeave" Grid.ColumnSpan="2" HorizontalAlignment="Right" IsTabStop="{TemplateBinding IsTabStop}"><br>    <span class="Apple-tab-span" style="white-space:pre">                    </span><Thumb.Style><br>    <span class="Apple-tab-span" style="white-space:pre">                       </span><Style TargetType="{x:Type Thumb}"><br>    <span class="Apple-tab-span" style="white-space:pre">                         </span><Setter Property="Width" Value="6"/><br>    <span class="Apple-tab-span" style="white-space:pre">                            </span><Setter Property="Background" Value="Transparent"/><br>    <span class="Apple-tab-span" style="white-space:pre">                         </span><Setter Property="BorderBrush" Value="Transparent"/><br>    <span class="Apple-tab-span" style="white-space:pre">                            </span><Setter Property="BorderThickness" Value="0"/><br>    <span class="Apple-tab-span" style="white-space:pre">                          </span><Setter Property="HorizontalContentAlignment" Value="Stretch"/><br>    <span class="Apple-tab-span" style="white-space:pre">                         </span><Setter Property="VerticalContentAlignment" Value="Stretch"/><br>    <span class="Apple-tab-span" style="white-space:pre">                           </span><Setter Property="Padding" Value="0"/><br>    <span class="Apple-tab-span" style="white-space:pre">                          </span><Setter Property="Cursor" Value="SizeWE"/><br>    <span class="Apple-tab-span" style="white-space:pre">                          </span><Setter Property="Template"><br>    <span class="Apple-tab-span" style="white-space:pre">                                </span><Setter.Value><br>    <span class="Apple-tab-span" style="white-space:pre">                                  </span><ControlTemplate TargetType="{x:Type Thumb}"><br>    <span class="Apple-tab-span" style="white-space:pre">                                       </span><Border BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Background="{TemplateBinding Background}" HorizontalAlignment="{TemplateBinding HorizontalContentAlignment}" Padding="{TemplateBinding Padding}" VerticalAlignment="{TemplateBinding VerticalContentAlignment}"/><br>    <span class="Apple-tab-span" style="white-space:pre">                                   </span></ControlTemplate><br>    <span class="Apple-tab-span" style="white-space:pre">                              </span></Setter.Value><br>    <span class="Apple-tab-span" style="white-space:pre">                         </span></Setter><br>    <span class="Apple-tab-span" style="white-space:pre">                       </span></Style><br>    <span class="Apple-tab-span" style="white-space:pre">                    </span></Thumb.Style><br>    <span class="Apple-tab-span" style="white-space:pre">              </span></Thumb><br>    <span class="Apple-tab-span" style="white-space:pre">            </span></Grid><br>    <span class="Apple-tab-span" style="white-space:pre">     </span></Border><br>    <span class="Apple-tab-span" style="white-space:pre">       </span><telerik:FieldFilterControl x:Name="PART_FieldFilterControl" Column="{x:Null}" IsTabStop="False" telerik:TouchManager.IsTouchHitTestVisible="False" Grid.Row="1" Visibility="{TemplateBinding FieldFilterControlVisibility}"/><br>    <span class="Apple-tab-span" style="white-space:pre">  </span></Grid><br>    </ControlTemplate>

and here is it's use
   
<telerik:RadGridView GroupPanelStyle="{DynamicResource TelerikGroupPanelStyle}"<br>                    Grid.Column="1" Grid.Row="1"<br>                        HorizontalAlignment="Stretch"<br>                        AutoGenerateColumns="False"<br>                             GroupPanelItemStyle="{DynamicResource TelerikGrpPanelItemStyle}"<br>                        VerticalAlignment="Stretch" HeaderRowStyle="{DynamicResource TelerikHeaderRowStyle}" ><br><br>            <telerik:RadGridView.Columns><br>                <telerik:GridViewDataColumn<br>                                Header="Nr"<br>                              HeaderCellStyle="{DynamicResource TelerikGridColumnHeaderStyle}"<br>                                Width="50" /><br>                <telerik:GridViewDataColumn<br>                                Header="{x:Static resx:LangResources._Description}"<br>                                HeaderCellStyle="{DynamicResource TelerikGridColumnHeaderStyle}"<br>                                Width="150" /><br>               <br>                <telerik:GridViewDataColumn<br>                                Header="{x:Static resx:LangResources._Quantity}"<br>                               HeaderCellStyle="{DynamicResource TelerikGridColumnHeaderStyle}"<br>                                TextAlignment="Right"<br>                                DataFormatString="0"<br>                                Width="70"  /><br>              <br>            </telerik:RadGridView.Columns><br>        </telerik:RadGridView>

as you can see it for each columns i had to specify HeaderCellStyle. when i dont specify it, column header does not take my style definition.
why it is so?
 
 
0
Vanya Pavlova
Telerik team
answered on 05 Nov 2013, 11:30 AM
Hello Pallavi,

 

Thank you for getting back to us!
Using the snippet provided we are not able to find what is the problem in your case.
Would it be possible to try to isolate the problem in a small runnable project and send it back to us as an attachment in a new support thread? 




Regards,
Vanya Pavlova
Telerik
TRY TELERIK'S NEWEST PRODUCT - EQATEC APPLICATION ANALYTICS for WPF.
Learn what features your users use (or don't use) in your application. Know your audience. Target it better. Develop wisely.
Sign up for Free application insights >>
Tags
GridView
Asked by
Pallavi
Top achievements
Rank 1
Answers by
Vanya Pavlova
Telerik team
Pallavi
Top achievements
Rank 1
Share this question
or