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

RadDiagramShape Style & DataTemplate

1 Answer 172 Views
Diagram
This is a migrated thread and some comments may be shown as answers.
Fabrizio
Top achievements
Rank 1
Fabrizio asked on 27 Nov 2012, 02:32 PM
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>

1 Answer, 1 is accepted

Sort by
0
Accepted
Tina Stancheva
Telerik team
answered on 30 Nov 2012, 11:31 AM
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.

Tags
Diagram
Asked by
Fabrizio
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Share this question
or