I have created a project that is using the sample in the code library http://www.telerik.com/community/code-library/silverlight/diagrams/partial-silverlight-conversion-of-the-financial-dashboard.aspx
This essentially a striped down version of the DashboardDesigner but for Silverlight.
I have created a new shape with a set of dependency properties, one of which is called Title. I have also created a corresponding object in the Toolbox for this item. When this object is dragged to the diagram surface I have opted to use the following Datatemplate:
Where the HeaderTemplate is
<DataTemplate x:Key="HeaderTemplate">
My problem is that I dont know what to set the datacontext to. I have tied a number of things to no avail. For example, in the BlahBlahToolboxItem where the actual shape is created on DragDrop
I have also tried to set the Datacontext to the Raddiagram after it is created.
What I am missing?
This essentially a striped down version of the DashboardDesigner but for Silverlight.
I have created a new shape with a set of dependency properties, one of which is called Title. I have also created a corresponding object in the Toolbox for this item. When this object is dragged to the diagram surface I have opted to use the following Datatemplate:
<DataTemplate x:Name="BlahBlahShape"> <Border BorderBrush="#FF87ACBE" BorderThickness="2" VerticalAlignment="Top" Grid.RowSpan="2" CornerRadius="5" Background="#FFF1FAFF"> <Grid x:Name="PART_maingrid"> <Grid.RowDefinitions> <RowDefinition Height="Auto" /> <RowDefinition Height="*" /> </Grid.RowDefinitions> <Border BorderBrush="#FF87ACBE" BorderThickness="0,0,0,1" VerticalAlignment="Top" CornerRadius="5,5,0,0" Background="#FFF1FAFF" Cursor="Hand" x:Name="PART_HeaderBorder"> <ContentPresenter x:Name="Header" HorizontalAlignment="Left" Content="{Binding}" Margin="0 4" ContentTemplate="{StaticResource HeaderTemplate}" /> </Border> <telerik:RadToggleButton Style="{StaticResource RadToggleButtonStyle}" Width="15" Height="17" IsChecked="True" x:Name="ShowHideButton" VerticalAlignment="Top" HorizontalAlignment="Right" Margin="0 6 6 0" /> <Border Background="White" Padding="0" BorderBrush="Transparent" Grid.Row="1" BorderThickness="1" CornerRadius="0" VerticalAlignment="Top"> </Border> </Grid> </Border> </DataTemplate>
Where the HeaderTemplate is
<DataTemplate x:Key="HeaderTemplate">
<Grid Width="184" Height="60"> <StackPanel Margin="5,2,0,0" HorizontalAlignment="Left"> <TextBlock x:Name="PART_Header" Text="{Binding Title}" Foreground="#FF000000" TextTrimming="WordEllipsis" TextWrapping="NoWrap" Width="Auto" MaxWidth="160" Height="20" FontFamily="Segoe UI Semibold" FontSize="12" /> <TextBlock x:Name="PART_SubHeader" Text="{Binding Path=Title}" Width="Auto" Height="Auto" TextWrapping="Wrap" FontSize="12" Foreground="#FF000000" FontFamily="Segoe UI" /> </StackPanel> </Grid>
My problem is that I dont know what to set the datacontext to. I have tied a number of things to no avail. For example, in the BlahBlahToolboxItem where the actual shape is created on DragDrop
public class TaskToolboxItem : ContentControl, IToolboxItem
{ public BlahBlahToolboxItem() { DefaultStyleKey = typeof(TaskToolboxItem); //Content = "Text"; } public RadDiagramShape CreateShape(Point position) { var shape = new TaskShape(); this.DataContext = shape; shape.Title = "Testing"; shape.Position = position; return shape; } }
I have also tried to set the Datacontext to the Raddiagram after it is created.
What I am missing?