- animationsamplecode.zip
- AnimationSampleCode
- AnimationSampleCode.sln
- AnimationSampleCode.suo
- AnimationSampleCode.Web
- AnimationSampleCode
- AnimationFirstExample.xaml
- AnimationFirstExample.xaml.cs
- AnimationSampleCode.csproj
- AnimationSampleCode.csproj.user
- AnimationWithCSharp.xaml
- AnimationWithCSharp.xaml.cs
- App.xaml
- App.xaml.cs
- Assets
- Bin
- Debug
- ActivityControl.dll
- AnimationSampleCode.dll
- AnimationSampleCode.xap
- AppManifest.xaml
- de
- System.ComponentModel.DataAnnotations.resources.dll
- System.Windows.Controls.Data.Input.resources.dll
- System.Windows.Controls.Navigation.resources.dll
- System.Windows.Controls.resources.dll
- System.Windows.Data.resources.dll
- es
- System.ComponentModel.DataAnnotations.resources.dll
- System.Windows.Controls.Data.Input.resources.dll
- System.Windows.Controls.Navigation.resources.dll
- System.Windows.Controls.resources.dll
- System.Windows.Data.resources.dll
- fr
- System.ComponentModel.DataAnnotations.resources.dll
- System.Windows.Controls.Data.Input.resources.dll
- System.Windows.Controls.Navigation.resources.dll
- System.Windows.Controls.resources.dll
- System.Windows.Data.resources.dll
- it
- System.ComponentModel.DataAnnotations.resources.dll
- System.Windows.Controls.Data.Input.resources.dll
- System.Windows.Controls.Navigation.resources.dll
- System.Windows.Controls.resources.dll
- System.Windows.Data.resources.dll
- ja
- System.ComponentModel.DataAnnotations.resources.dll
- System.Windows.Controls.Data.Input.resources.dll
- System.Windows.Controls.Navigation.resources.dll
- System.Windows.Controls.resources.dll
- System.Windows.Data.resources.dll
- ko
- System.ComponentModel.DataAnnotations.resources.dll
- System.Windows.Controls.Data.Input.resources.dll
- System.Windows.Controls.Navigation.resources.dll
- System.Windows.Controls.resources.dll
- System.Windows.Data.resources.dll
- System.ComponentModel.DataAnnotations.dll
- System.ComponentModel.DataAnnotations.xml
- System.Windows.Controls.Data.DataForm.Toolkit.dll
- System.Windows.Controls.Data.Input.dll
- System.Windows.Controls.Data.Input.xml
- System.Windows.Controls.dll
- System.Windows.Controls.Navigation.dll
- System.Windows.Controls.Navigation.xml
- System.Windows.Controls.xml
- System.Windows.Data.dll
- System.Windows.Data.xml
- System.Windows.Ria.dll
- System.Windows.Ria.xml
- TestPage.html
- zh-Hans
- System.ComponentModel.DataAnnotations.resources.dll
- System.Windows.Controls.Data.Input.resources.dll
- System.Windows.Controls.Navigation.resources.dll
- System.Windows.Controls.resources.dll
- System.Windows.Data.resources.dll
- zh-Hant
- System.ComponentModel.DataAnnotations.resources.dll
- System.Windows.Controls.Data.Input.resources.dll
- System.Windows.Controls.Navigation.resources.dll
- System.Windows.Controls.resources.dll
- System.Windows.Data.resources.dll
- Controls
- Generated_Code
- Helpers
- Libs
- ActivityControl.dll
- System.Windows.Controls.Data.DataForm.Toolkit.dll
- MainPage.xaml
- MainPage.xaml.cs
- Models
- Properties
- Views
- Web
- Resources
|
namespace AnimationSampleCode
{
using System;
using System.ComponentModel;
using System.Windows;
using System.Windows.Data;
/// <summary>
/// Provides extension methods for dealing with <see cref="Binding"/> objects
/// </summary>
public static class DataBindingExtensions
{
/// <summary>
/// Creates a new <see cref="Binding"/> whose <see cref="Binding.Source"/>
/// is the object in which this method is being called, whose <see cref="Binding.Path"/>
/// property is initialized from <see cref="propertyPath"/>
/// </summary>
public static Binding CreateOneWayBinding(this INotifyPropertyChanged bindingSource, string propertyPath)
{
return bindingSource.CreateOneWayBinding(propertyPath, null);
}
/// <summary>
/// Creates a new <see cref="Binding"/> whose <see cref="Binding.Source"/>
/// is the object in which this method is being called, whose <see cref="Binding.Path"/>
/// property is initialized from <see cref="propertyPath"/> and whose <see cref="Binding.Converter"/>
/// property is a one-way <see cref="LambdaValueConverter"/> object whose converter
/// is given by <paramref name="converter"/>
/// </summary>
public static Binding CreateOneWayBinding(this INotifyPropertyChanged bindingSource, string propertyPath, IValueConverter converter)
{
Binding binding = new Binding();
binding.Source = bindingSource;
binding.Path = new PropertyPath(propertyPath);
binding.Converter = converter;
return binding;
}
/// <summary>
/// Creates a new <see cref="Binding"/> object by copying all properties
/// from another <see cref="Binding"/> object
/// </summary>
/// <param name="binding"><see cref="Binding"/> from which property values will be copied</param>
public static Binding CreateCopy(this Binding binding)
{
Binding newBinding = new Binding()
{
BindsDirectlyToSource = binding.BindsDirectlyToSource,
Converter = binding.Converter,
ConverterParameter = binding.ConverterParameter,
ConverterCulture = binding.ConverterCulture,
Mode = binding.Mode,
NotifyOnValidationError = binding.NotifyOnValidationError,
Path = binding.Path,
UpdateSourceTrigger = binding.UpdateSourceTrigger,
ValidatesOnExceptions = binding.ValidatesOnExceptions
};
if (binding.ElementName != null)
{
newBinding.ElementName = binding.ElementName;
}
else if (binding.RelativeSource != null)
{
newBinding.RelativeSource = binding.RelativeSource;
}
else
{
newBinding.Source = binding.Source;
}
return newBinding;
}
}
}
|
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.