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

Custom Styles make Shapes disappear

2 Answers 172 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
KALLINA
Top achievements
Rank 1
KALLINA asked on 05 Jan 2018, 07:34 AM

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 Answers, 1 is accepted

Sort by
0
Accepted
Martin Ivanov
Telerik team
answered on 05 Jan 2018, 09:28 AM
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.
0
KALLINA
Top achievements
Rank 1
answered on 05 Jan 2018, 10:06 AM

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

Thank you very much!
Dimitris

Tags
Diagram
Asked by
KALLINA
Top achievements
Rank 1
Answers by
Martin Ivanov
Telerik team
KALLINA
Top achievements
Rank 1
Share this question
or