I have a ViewModel which loads a list in a list.xaml. If something is clicked in the list.xaml a detail.xaml is opened
Now in this detail.xaml I have first a grid with some information about the clicked list item (description etc.) and below I want to show a RadDiagram with shapes.
To achieve this I have a property in my ViewModel which creates a object GraphSource of ObservableGraphSourceBase and returns it.
For simplicity the object just have a constructor with the following code:
1.Public Sub New()2. Dim warenEingang = New NodeViewModelBase With {.Content = "Wareneingang", .Position = New Point(40, 40)}3. Dim waschhaus = New NodeViewModelBase With {.Content = "Waschhaus", .Position = New Point(40, 80)}4. Dim warenAusgang = New NodeViewModelBase With {.Content = "Warenausgang", .Position = New Point(40, 120)}5. MyBase.AddNode(warenEingang)6. MyBase.AddNode(waschhaus)7. MyBase.AddNode(warenAusgang)8.End Sub
In the ViewModel the property looks like this:
1.Public ReadOnly Property myGraphProperty()2. Get3. Dim graphSource = New GraphSource()4. Return graphSource5. End Get6.End Property
Now on my detail.xaml the stuff for my RadDiagram is loaded from an external xaml, let's call it "raddiagram.xaml"
1.<!-- detail.xaml-->2.<UserControl x:Class="detail" [...]>3. <!-- grid implementation -->4. <local:raddiagram.xaml />5.</UserControl>
Finally I'min the raddiagram.xaml :-)
01.<UserControl x:Class="raddiagram"03. xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"04. xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"05. xmlns:d="http://schemas.microsoft.com/expression/blend/2008"06. xmlns:local="clr-namespace:Views"07. xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"08. xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"09. mc:Ignorable="d"10. d:DesignHeight="800" d:DesignWidth="800">11.<Grid x:Name="LayoutRoot">12. <telerik:RadDiagram x:Name="diagram" GraphSource="{Binding myGraphProperty}" />13. 14. <telerik:RadTreeView x:Name="tree" Grid.Column="1" Width="300" ItemsSource="{Binding Items}">15. <telerik:RadTreeView.ItemTemplate>16. <DataTemplate>17. <TextBlock Text="{Binding Content}" />18. </DataTemplate>19. </telerik:RadTreeView.ItemTemplate>20. </telerik:RadTreeView>21.</Grid>22.</UserControl>
With this example xaml - taken from the documentation --> two-way-mvvm , my shapes are shown (still the content needs a toString, but this is not the big problem here).
Unfortunately all shapes are laying at position (0,0) - but when trying to achieve anything written in with styles / templates nothing is shown anymore.
Question: How can I achieve, via a property access of a ViewModel, that I can "iterate" in my xaml over all shapes to style them (setter property position etc.).
The goal is (later) after the three shapes are shown correctly (as you can see above, the x-position is the same, but y- is increasing) to insert connections between them.
I tried this: http://docs.telerik.com/devtools/wpf/controls/raddiagram/howto/mvvm-style-selectors but then nothing (shapes) is shown anymore on the RadDiagram.
Thanks for any hints/help
Timon
