RadDiagramShape Style & DataTemplate

2 posts, 1 answers
  1. Fabrizio
    Fabrizio avatar
    9 posts
    Member since:
    Nov 2012

    Posted 27 Nov 2012 Link to this post

    hi all, can u help me to understand what's wrong in this style?

    PocVertex is a ViewModel object representing the diagram Node.

    <Style x:Key="PocNodeStyle" TargetType="telerik:RadDiagramShape">
            <Setter Property="Position" Value="{Binding Position, Mode=TwoWay}" />
            <Setter Property="Width" Value="200" />
            <Setter Property="Height" Value="50" />
            <Setter Property="IsConnectorsManipulationEnabled" Value="False" />
            <Setter Property="IsRotationEnabled" Value="False" />
            <Setter Property="Template">
                <Setter.Value>
                    <DataTemplate DataType="{x:Type local:PocVertex}">
                        <ContentControl>
                            <Border Name="bd" Background="#FFE3E3E3"
                                    BorderBrush="{Binding Path=.,Converter={StaticResource nodeBorderColorConverter}}"
                                    BorderThickness="5,3,5,3"
                                    CornerRadius="10,10,10,10"
                                    Padding="10,5,10,5">
                                <Border.ContextMenu>
                                    <ContextMenu    >
                                        <MenuItem x:Name="miCollega"                              Header="collega con" />
                                        <MenuItem x:Name="miCollega_Opzione"                      Header="collega con opzione" />
                                        <MenuItem x:Name="miElimina"                              Header="elimina" />
                                        <MenuItem x:Name="miElimina_Collegamenti"                 Header="elimina collegamenti" />
                                        <MenuItem x:Name="miRadice"                               Header="Imposta come radice" />
                                        <MenuItem x:Name="miDuplica"                              Header="duplica nodo" />
                                        <MenuItem x:Name="miCopiaNodo"                            Header="copia nodo" />
                                        <MenuItem x:Name="miEmail"                                Header="invia email"           />
                                        <!--ItemsSource="{Binding Source={x:Static s:Settings.Default}, Path=Emails, Mode=TwoWay}"-->
                                        <MenuItem x:Name="miNuovo"                                    Header="nuovo nodo"  >
                                            <MenuItem x:Name="miNuovo_Diretto"                        Header="diretto" />
                                            <MenuItem x:Name="miNuovo_Opzione"                        Header="opzione" />
                                        </MenuItem>
                                        <MenuItem x:Name="miIsolaNodo"                                Header="isola nodo" />
                                    </ContextMenu>
                                </Border.ContextMenu>
                                <TextBlock Name="txtCaption" Text="{Binding Caption}"  ToolTip="{Binding Text}"/>
                            </Border>
                        </ContentControl>
                        <DataTemplate.Triggers>
                            <DataTrigger Binding="{Binding Path=IsRoot}" Value="True">
                                <DataTrigger.Setters>
                                    <Setter Property="TextDecorations" Value="Underline" TargetName="txtCaption" />
                                </DataTrigger.Setters>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding Path=IsHighlighted}" Value="True">
                                <DataTrigger.Setters>
                                    <Setter Property="BorderBrush" Value="Red" TargetName="bd" />
                                </DataTrigger.Setters>
                            </DataTrigger>
                            <DataTrigger Binding="{Binding Path=IsSelected}" Value="True">
                                <DataTrigger.Setters>
                                    <Setter Property="Background" Value="Yellow" TargetName="bd" />
                                </DataTrigger.Setters>
                            </DataTrigger>
                        </DataTemplate.Triggers>
                    </DataTemplate>
                </Setter.Value>
            </Setter>
        </Style>
  2. Answer
    Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 30 Nov 2012 Link to this post

    Hi Fabrizio,

    In the solution you posted in your other thread, I noticed that you've fixed the issue. However, just in case anyone else encounters the same, I want to note that the Template property of the RadDiagramShape is of type ControlTemplate. So you need to apply a custom ControlTemplate rather than DataTemplate.

    Regards,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

  3. UI for WPF is Visual Studio 2017 Ready
Back to Top