csharpc-sharpdotnetxamlavaloniauicross-platformcross-platform-xamlavaloniaguimulti-platformuser-interfacedotnetcore
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
44 lines
1.1 KiB
44 lines
1.1 KiB
// -----------------------------------------------------------------------
|
|
// <copyright file="Setter.cs" company="Steven Kirk">
|
|
// Copyright 2014 MIT Licence. See licence.md for more information.
|
|
// </copyright>
|
|
// -----------------------------------------------------------------------
|
|
|
|
namespace Perspex
|
|
{
|
|
using System;
|
|
using System.Diagnostics.Contracts;
|
|
using Perspex.Controls;
|
|
|
|
public class Setter
|
|
{
|
|
private object oldValue;
|
|
|
|
public PerspexProperty Property
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
public object Value
|
|
{
|
|
get;
|
|
set;
|
|
}
|
|
|
|
public void Apply(Control control)
|
|
{
|
|
Contract.Requires<NullReferenceException>(control != null);
|
|
|
|
this.oldValue = control.GetValue(this.Property);
|
|
control.SetValue(this.Property, this.Value);
|
|
}
|
|
|
|
public void Unapply(Control control)
|
|
{
|
|
Contract.Requires<NullReferenceException>(control != null);
|
|
|
|
control.SetValue(this.Property, this.oldValue);
|
|
}
|
|
}
|
|
}
|
|
|