Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
1160
How to Differentiate Text Control and Rectangle in XAMDiagram to make editing?
posted

Hi,

We are using XAMDiagram and we are able to get all shape types. But Now we want that If  Shape Type is only Text Control  we can edit and want to stop editing Text in rest of the controls. But In Text Control have same property as Rectangle like shape Type and etc?. so we are not able to differentiate Text Control and Rectangle. along with that how can we stop Text editing in Diagram shape controls. Please Help us your help would be appreciate.

Thanks

  • 17475
    Offline posted

    Hello Pra,

    The Rectangle and the Text element has a different value for the Stroke property though they are both rectangles so this can be used to differentiate them
    <Style TargetType="{x:Type ig:DiagramNode}">
                <Setter Property="EditTemplate">
                    <Setter.Value>
                        <DataTemplate>
                            <TextBlock Text="{Binding Content, RelativeSource={RelativeSource AncestorType=ig:DiagramNode}}"
                                               HorizontalAlignment="Center"
                                               VerticalAlignment="Center"/>

                        </DataTemplate>
                    </Setter.Value>
                </Setter>
                <Style.Triggers>
                    <Trigger Property="Stroke" Value="Transparent">
                        <Setter Property="EditTemplate">
                            <Setter.Value>
                                <DataTemplate>
                                    <TextBox Text="{Binding Content, RelativeSource={RelativeSource AncestorType=ig:DiagramNode}, Mode=TwoWay}"
                                               HorizontalAlignment="Center"
                                               VerticalAlignment="Center"/>

                                </DataTemplate>
                            </Setter.Value>
                        </Setter>
                    </Trigger>
                </Style.Triggers>
              
            </Style>

    Let me know if you have any other questions or concerns on the same.