예제 #1
0
        /// <summary>
        /// Creates a binding and sets it on the element, guarding against pre-existing bindings.
        /// </summary>
        /// <param name="viewModel">The view model (dataSource).</param>
        /// <param name="path">The dataMember.</param>
        /// <param name="property">The binding property.</param>
        /// <param name="element">The control element.</param>
        /// <param name="convention">The element convention.</param>
        /// <returns>
        ///     <c>true</c> if the specified property already has a binding on the provided control; otherwise, <c>false</c>.
        /// </returns>
        /// <remarks>The binding will be set as explained below<br/>
        /// Binding(convention.BindingPropertyName, viewModel, path)<br/>
        /// Binding(string propertyName, object dataSource, string dataMember)</remarks>
        public static bool SetBindingWithoutBindingOverwrite(object viewModel, string path, PropertyInfo property,
                                                             Control element, ElementConvention convention)
        {
            if (HasBinding(element, path))
            {
                return(false);
            }

            SetBinding(viewModel, path, property, element, convention);
            return(true);
        }
예제 #2
0
 /// <summary>
 /// Adds an element convention.
 /// </summary>
 /// <param name="convention">The <see cref="ElementConvention"/> to add.</param>
 /// <returns>The added element convention.</returns>
 public static ElementConvention AddElementConvention(ElementConvention convention)
 {
     return(ControlConventions[convention.ElementType] = convention);
 }