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

Caliburn Micro and RadTileView

2 Answers 139 Views
TileView
This is a migrated thread and some comments may be shown as answers.
Tim
Top achievements
Rank 1
Tim asked on 08 Sep 2011, 06:11 PM
Hello.

I tried to rewrite the SimpleMDI caliburn micro sample to use a RadTileView with Conductor<...>.Collection.AllActive. (Unfortunately I am not allowed to upload a sample project). As I understood from several resources on the web, I need to add custom conventions to get this working. I tried a lot of stuff and finally ended with
static void AddCustomConventions()
{
    ConventionManager.AddElementConvention<RadTileView>(RadTileView.ContentTemplateProperty, "DataContext", "Loaded");
}

but unfortunately with no luck! My XAML looks like this and I think it should find the View for the ContentTemplate from the ViewModel - but id doesn't:
<UserControl x:Class="Caliburn.Micro.HelloMef.ShellView"
             xmlns:telerik="http://schemas.telerik.com/2008/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" >
    <Grid x:Name="LayoutRoot">
        <telerik:RadTileView ItemsSource="{Binding Items}">
            <telerik:RadTileView.ItemTemplate>
                <DataTemplate>
                    <TextBlock Text="{Binding DisplayName}" />
                </DataTemplate>
            </telerik:RadTileView.ItemTemplate>
        </telerik:RadTileView>
    </Grid>
</UserControl>

Has anyone experience with Caliburn Micro combined with Telerik?
Thanks A LOT for any kind of information and help!
All the best,
Tim.

2 Answers, 1 is accepted

Sort by
0
S
Top achievements
Rank 1
answered on 14 Sep 2011, 03:11 AM
Hello Tim,

   Let me prefix this comment/answer with two things:
  1. I'm new to Telerik controls
  2. I'm definitely new to the whole MVVM thing and Caliburn Micro is my first attempt at using it :)

So please keep that in mind... I had a similar goal to yours with a grid of MEF facilitated Views loaded into child controls in a RadTileView. They may take my MVVM license away for doing it this way, but the ONLY way I could get the views to connect with the right Model in the TileView / FluidContentControl was to explicitly make the binding in the XAML of each of the user controls that were to be placed in the Tiles. That is - I had to use some of the "view first" features of Caliburn Micro :

  • I had to add the appropriate MEF decoration to the ViewModel class... In my case it was: 
        [Export ("AverageScoreChartViewModel", typeof(AverageScoreChartViewModel))]
        public class AverageScoreChartViewModel : PropertyChangedBase, IDashboardItem
        {
           // where IDashboardItem is simply used to connect to my chart dashboard to tile items (i.e. name, minimized icon, header items, etc
             ...
       }

  • Then in the UserControl View (for this snippet - AverageScoreChartView ) that is to be placed within the TileViewItem, I had to make the binding to the right model explicit by using this syntax in the UserControl attributes (where cal is the caliburn namespace). This let's MEF and CM wire up everything
<UserControl
    xmlns:cal="clr-namespace:Caliburn.Micro;assembly=Caliburn.Micro"
    x:Class="MyProject.Namespaces.Dashboard.AverageScoreChartView"
    mc:Ignorable="d"
    cal:Bind.Model="AverageScoreChartViewModel"
    d:DesignHeight="300" d:DesignWidth="400" >
     
<!-- All my controls and junk go here within a RadFluidContentControl that is set to ContentChangedMode="Manual" -->
 
</UserControl>

I'm pretty sure I'm not specifically answering your question, but I hope this helps - and as I say it's probably the "wrong" way, but I just needed it to work ;)

Cheers!
Wilks
0
Tim
Top achievements
Rank 1
answered on 10 Nov 2011, 02:42 PM
Hi Wilks, thanks a lot for answering and sorry for my late reply!

After reading http://caliburnmicro.codeplex.com/wikipage?title=All%20About%20Conventions&referringTitle=Documentation a thousand of times, I realized that there is no problem in using Telerik. The only problem is the DataTemplate and one has to use something like cal:View.Model="{Binding}" or even cal:View.Model="{Binding ActiveItem}". I was a little bit confused due to the ConventionManager stuff and now I am happy that I don't even have to use it! :)

Thanks again Wilks for your help!
All the best,
Tim.
Tags
TileView
Asked by
Tim
Top achievements
Rank 1
Answers by
S
Top achievements
Rank 1
Tim
Top achievements
Rank 1
Share this question
or