Click here to Skip to main content
15,885,244 members
Articles / Desktop Programming / WPF

Caliburn - Modules, Windows, and Actions

Rate me:
Please Sign up or sign in to vote.
5.00/5 (12 votes)
10 Mar 2010CPOL6 min read 50.7K   1.1K   49  
This article demonstrates breaking out of the shell with module development and using Caliburn actions.
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows.Data;

namespace emx.tcp.caliburn.loading.modules.moduleB.Controls
{
    /// <summary>
    /// Base class for multivalue converters that do not implement the ConvertBack method
    /// </summary>
    public abstract class OneWayMultiValueConverter : IMultiValueConverter
    {
        /// <summary>
        /// Converts a value. Used in data binding. Override this method (sealed).
        /// </summary>
        /// <param name="values">The array of values that the source bindings in the MultiBinding produces</param>
        /// <param name="targetType">The type of the binding target property</param>
        /// <param name="parameter">The converter parameter to use</param>
        /// <param name="culture">The culture to use in the converter</param>
        /// <returns>A converted value</returns>
        public abstract object Convert(object[] values, Type targetType, object parameter, System.Globalization.CultureInfo culture);

        /// <summary>
        /// Unimplemented method for converting back. This converter can only be used for one-way binding.
        /// </summary>
        /// <param name="value">Unused parameter</param>
        /// <param name="targetTypes">Unused parameter</param>
        /// <param name="parameter">Unused parameter</param>
        /// <param name="culture">Unused parameter</param>
        /// <returns>Always throws an exception</returns>
        public object[] ConvertBack(object value, Type[] targetTypes, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotSupportedException("This is a one-way value converter. ConvertBack method is not supported.");
        }
    }

    /// <summary>
    /// Base class for value converters that do not implement the ConvertBack method.
    /// </summary>
    public abstract class OneWayValueConverter : IValueConverter
    {
        /// <summary>
        /// Converts a value. Used in data binding. Override this method (sealed).
        /// Decorate the method with the type of return data (ValueConversion attribute).
        /// </summary>
        /// <param name="value">The value produced by the binding source</param>
        /// <param name="targetType">The type of the binding target property</param>
        /// <param name="parameter">The converter parameter to use</param>
        /// <param name="culture">The culture to use in the converter</param>
        /// <returns>A converted value</returns>
        public abstract object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture);

        /// <summary>
        /// Unimplemented method for converting back. This converter can only be used for one-way binding.
        /// </summary>
        /// <param name="value">Unused parameter</param>
        /// <param name="targetType">Unused parameter</param>
        /// <param name="parameter">Unused parameter</param>
        /// <param name="culture">Unused parameter</param>
        /// <returns>Always throws an exception</returns>
        public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
        {
            throw new NotSupportedException("This is a one-way value converter. ConvertBack method is not supported.");
        }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Software Developer Encore Software
Australia Australia
Contractor in Desktop and Web applications.
Gold Coast, Queensland.

Comments and Discussions