Custom Styles make Shapes disappear

3 posts, 1 answers
  1. KALLINA
    KALLINA avatar
    2 posts
    Member since:
    Nov 2016

    Posted 05 Jan Link to this post

    Hello,

    I am trying to create a Diagram, using RadDiagram, and I want to apply some custom styles using StyleSelectors.

    My main issue is that when I apply a ShapeStyle to a RadDiagram (even static) then the shapes disappear!The same happens with the connections.

    Even the simplest examples from Customize the RadDiagramShape Style do not work! I use Telerik 2017.3.1018.45.NoXaml version and I have added the following dictionaries:

    <ResourceDictionary Source="/Telerik.Windows.Themes.Summer;component/Themes/System.Windows.xaml" />
    <ResourceDictionary Source="/Telerik.Windows.Themes.Summer;component/Themes/Telerik.Windows.Controls.xaml" />
    <ResourceDictionary Source="/Telerik.Windows.Themes.Summer;component/Themes/Telerik.Windows.Controls.Diagrams.xaml" />

     

    My MainWindow.Xaml

    <Window x:Class="TestingDiagram.MainWindow"
            xmlns:local="clr-namespace:TestingDiagram"
            mc:Ignorable="d"
            Title="MainWindow" Height="350" Width="525">
        <Grid>
            <Grid.Resources>
                <Style TargetType="telerik:RadDiagramShape" x:Key="CustomShapeStyle">
                    <Setter Property="Background" Value="LightGreen" />
                    <Setter Property="FontWeight" Value="Bold" />
                </Style>
            </Grid.Resources>
            <telerik:RadDiagram x:Name="xDiagram" ShapeStyle="{StaticResource CustomShapeStyle}">
                <telerik:RadDiagramShape x:Name="shape1" Position="20,20" Content="Shape 1" />
                <telerik:RadDiagramShape x:Name="shape2" Position="220,20" Content="Shape 2" />
                <telerik:RadDiagramConnection Source="{Binding ElementName=shape1}"
                    Target="{Binding ElementName=shape2}" />
            </telerik:RadDiagram>
        </Grid>
    </Window>

    Thanks in advance
    Dimitris

  2. Answer
    Martin Ivanov
    Admin
    Martin Ivanov avatar
    1647 posts

    Posted 05 Jan Link to this post

    Hello Dimitris,

    This happens because the custom style is not based on the default style of the control. Note that this is required only when you use NoXaml dlls. To resolve this you can set the BasedOn property of the shape style like this:
    <Style TargetType="telerik:RadDiagramShape" x:Key="CustomShapeStyle" BasedOn="{StaticResource RadDiagramShapeStyle}">
        <Setter Property="Background" Value="LightGreen" />
        <Setter Property="FontWeight" Value="Bold" />
    </Style>

    Regards,
    Martin Ivanov
    Progress Telerik
    Want to extend the target reach of your WPF applications, leveraging iOS, Android, and UWP? Try UI for Xamarin, a suite of polished and feature-rich components for the Xamarin framework, which allow you to write beautiful native mobile apps using a single shared C# codebase.
  3. KALLINA
    KALLINA avatar
    2 posts
    Member since:
    Nov 2016

    Posted 05 Jan in reply to Martin Ivanov Link to this post

    I narrowed it down to something like this but I didn't know the base class!

    Thank you very much!
    Dimitris

Back to Top