本文整理汇总了C#中System.Windows.DependencyObject.SetEffectiveValue方法的典型用法代码示例。如果您正苦于以下问题:C# DependencyObject.SetEffectiveValue方法的具体用法?C# DependencyObject.SetEffectiveValue怎么用?C# DependencyObject.SetEffectiveValue使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.DependencyObject
的用法示例。
在下文中一共展示了DependencyObject.SetEffectiveValue方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SetItemValuesOnContainer
/// <summary>
/// Sets all values saved in ItemValueStorage for the given item onto the container
/// </summary>
/// <param name="container"></param>
/// <param name="item"></param>
private void SetItemValuesOnContainer(DependencyObject container, object item, int[] dpIndices)
{
List<KeyValuePair<int, object>> itemValues = GetItemValues(item);
if (itemValues != null)
{
for (int i = 0; i < itemValues.Count; i++)
{
int dpIndex = itemValues[i].Key;
for (int j = 0; j < dpIndices.Length; j++)
{
if (dpIndex == dpIndices[j])
{
object value = itemValues[i].Value;
EntryIndex entryIndex = container.LookupEntry(dpIndex);
ModifiedItemValue modifiedItemValue = value as ModifiedItemValue;
DependencyProperty dp = DependencyProperty.RegisteredPropertyList.List[dpIndex];
if (modifiedItemValue == null)
{
// set as local value
if (dp != null)
{
// for real properties, call SetValue so that the property's
// change-callback is called
container.SetValue(dp, value);
}
else
{
// for "fake" properties (no corresponding DP - e.g. VSP's desired-size),
// set the property directly into the effective value table
container.SetEffectiveValue(entryIndex, null /*dp*/, dpIndex, null /*metadata*/, value, BaseValueSourceInternal.Local);
}
}
else if (modifiedItemValue.IsCoercedWithCurrentValue)
{
// set as current-value
container.SetCurrentValue(dp, modifiedItemValue.Value);
}
break;
}
}
}
}
}