SimpleMDI - TabControl to Telerik RadTileView

Topics: Conventions
Sep 9, 2011 at 10:29 AM


I hope someone can help me. I am using the SimpleMDI sample and all I want to do is to change the tab control to a telerik radtileview.

Sample Code:
<TabControl x:Name="Items">
                    <StackPanel Orientation="Horizontal">
                        <TextBlock Text="{Binding DisplayName}" />
                        <Button Content="X" cal:Message.Attach="DeactivateItem($dataContext, 'true')" />

Modified Code:
<telerik:RadTileView x:Name="Items">
                    <StackPanel Orientation="Horizontal"> <TextBlock Text="{Binding DisplayName}" />
                        <Button Content="X"
                                cal:Message.Attach="DeactivateItem($dataContext, 'true')" />

Using the modified code, the view is not found. Reading several posts, I now know that I have to use custom conventions.
I tried it - with no luck! I ended with something like


.ContentTemplateProperty, ...

but it just doesn't work. What conventions do I have to add to get this modified sample working?
Thanks A LOT for any information and help!

All the best and greetings,

Sep 12, 2011 at 12:16 PM

I use different approach. I try to find public properties and treat them as fields to assign.  
Sample convention manager is below...  



using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Reflection;
using System.Windows;
using Caliburn.Micro;

namespace PATI.Bootstrapper.Caliburn.Micro.Conventions
    public class Conventions
        public static void Configure()

        private static void ValidationConvention()
            ConventionManager.ApplyValidation = (binding, viewModelType, property) =>
                // Original code
                if (typeof(INotifyDataErrorInfo).IsAssignableFrom(viewModelType))
                    binding.ValidatesOnNotifyDataErrors = true;

                if (typeof(IDataErrorInfo).IsAssignableFrom(viewModelType))
                    binding.ValidatesOnDataErrors = true;

                // New code
                //binding.ValidatesOnExceptions = true;
                //binding.NotifyOnValidationError = true;


        private static void BindingScope_GetNamedElements_Convention()
            BindingScope.GetNamedElements = GetFields;
        static Dictionary<Type, List<FieldInfo>> _typeCache = new Dictionary<Type, List<FieldInfo>>();

        static IEnumerable<FrameworkElement> GetFields(DependencyObject obj)
            var fields = GetFields(obj.GetType());
            if (fields != null)
                foreach (var f in fields)
                    var result = f.GetValue(obj) as FrameworkElement;
                    if (result != null)
                        yield return result;

        static IEnumerable<FieldInfo> GetFields(Type type)
            List<FieldInfo> result;

            if (_typeCache.TryGetValue(type, out result))
                return result;

            result = type.
              GetFields(BindingFlags.Instance | BindingFlags.Public | BindingFlags.NonPublic).
              Where(i => typeof(FrameworkElement).IsAssignableFrom(i.FieldType)).ToList();

            if (result.Count == 0)
                result = null;

            _typeCache[type] = result;

            return result;

Sep 12, 2011 at 2:53 PM

Thanks a lot for your help! But unfortunately I don't get this sample to work the way I want to... :(
Any further help is greatly appreciated!!!

Thanks in advance,