This question is locked. New answers and comments are not allowed.
I have created an application that is somewhat similiar to the Dashboard designer except in SL. Following the approach demonstrated in the DD I have a DataTemplate such as:
GENERIC.XAML
This style is defined in generic.xaml because I need the RadDiagramShapeStyle
So, now how do I setup a event on the RadButton click?
No matter what I do I cant find the button in code in order to wire up an eventhandler. Perhaps in this case I should use a ControlTemplate like so:
If I do that I can find the button in code, but when I drop this style on to the diagram surface, it comes across as width=0, height=0, but much worse, although I can select the object I cannot move it on the diagram the way I could before when using a datatemplate.
Any suggestions?
GENERIC.XAML
<ResourceDictionary.MergedDictionaries> <ResourceDictionary Source="/Telerik.Windows.Controls.Diagrams;Component/Themes/office/black/DiagramShapes.xaml"/> </ResourceDictionary.MergedDictionaries>
<Style TargetType="local:ASResourceShape" BasedOn="{StaticResource RadDiagramShapeStyle}"> <Setter Property="Background" Value="Wheat" /> <Setter Property="BorderBrush" Value="Black" /> <Setter Property="HorizontalContentAlignment" Value="Stretch" /> <Setter Property="VerticalContentAlignment" Value="Stretch" /> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate > <telerik:RadButton Grid.Row="1" Grid.Column="1" Name="ASRRadButton" Content="{Binding Path=Content, Mode=TwoWay, RelativeSource={RelativeSource AncestorType=local:ASResourceShape}}" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=local:ASResourceShape}}" Margin="0,0,0,0" MaxWidth="800" FontSize="{Binding Path=FontSize, RelativeSource={RelativeSource AncestorType=local:ASResourceShape}, Mode=TwoWay}" FontWeight="{Binding Path=FontWeight, RelativeSource={RelativeSource AncestorType=local:ASResourceShape}}" /> </DataTemplate> </Setter.Value> </Setter> </Style>
This style is defined in generic.xaml because I need the RadDiagramShapeStyle
So, now how do I setup a event on the RadButton click?
No matter what I do I cant find the button in code in order to wire up an eventhandler. Perhaps in this case I should use a ControlTemplate like so:
<Setter Property="Template"> <Setter.Value> <ControlTemplate TargetType="local:ASResourceShape"> <telerik:RadButton Grid.Row="1" Grid.Column="1" Name="ASResource" Content="{Binding Path=Content, Mode=TwoWay, RelativeSource={RelativeSource AncestorType=local:ASResourceShape}}" Foreground="{Binding Path=Foreground, RelativeSource={RelativeSource AncestorType=local:ASResourceShape}}" Margin="0,0,0,0" MaxWidth="800" FontSize="{Binding Path=FontSize, RelativeSource={RelativeSource AncestorType=local:ASResourceShape}, Mode=TwoWay}" FontWeight="{Binding Path=FontWeight, RelativeSource={RelativeSource AncestorType=local:ASResourceShape}}" /> </ControlTemplate> </Setter.Value> </Setter>
If I do that I can find the button in code, but when I drop this style on to the diagram surface, it comes across as width=0, height=0, but much worse, although I can select the object I cannot move it on the diagram the way I could before when using a datatemplate.
Any suggestions?