mirror of
https://github.com/chylex/Backup-Essentials.git
synced 2025-07-25 22:59:02 +02:00
Added binding updating extension method
This commit is contained in:
parent
33a1eb079a
commit
a64f4574a6
BackupEssentials
@ -140,6 +140,7 @@
|
||||
<Compile Include="Utils\ProgramArgsParser.cs" />
|
||||
<Compile Include="Utils\ScheduledUpdate.cs" />
|
||||
<Compile Include="Utils\WindowsVersion.cs" />
|
||||
<Compile Include="Utils\WpfExtensions.cs" />
|
||||
<Page Include="BackupReportWindow.xaml">
|
||||
<SubType>Designer</SubType>
|
||||
<Generator>MSBuild:Compile</Generator>
|
||||
|
29
BackupEssentials/Utils/WpfExtensions.cs
Normal file
29
BackupEssentials/Utils/WpfExtensions.cs
Normal file
@ -0,0 +1,29 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Windows;
|
||||
using System.Windows.Data;
|
||||
using System.Windows.Media;
|
||||
|
||||
namespace BackupEssentials.Utils{
|
||||
static class WpfExtensions{
|
||||
public static IEnumerable<DependencyObject> EnumerateMeAndChildren(this DependencyObject obj){
|
||||
yield return obj;
|
||||
|
||||
for(int a = 0; a < VisualTreeHelper.GetChildrenCount(obj); a++){
|
||||
foreach(DependencyObject child in VisualTreeHelper.GetChild(obj,a).EnumerateMeAndChildren()){
|
||||
yield return child;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static void UpdateBindings(this DependencyObject parent){
|
||||
foreach(DependencyObject obj in parent.EnumerateMeAndChildren()){
|
||||
LocalValueEnumerator enumerator = obj.GetLocalValueEnumerator();
|
||||
|
||||
while(enumerator.MoveNext()){
|
||||
BindingExpressionBase binding = BindingOperations.GetBindingExpressionBase(obj,enumerator.Current.Property);
|
||||
if (binding != null)binding.UpdateTarget();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user