DependencyObject as Binding Proxy not working since update from 2.2.3 to 3.1.2
Posted: 30 Dec 2021, 13:11
To avoid spamming XAML files with confusing AnchestorType bindings, we were using DepencendyObjects as Binding Proxies as described in this Blog:
https://code.4noobz.net/wpf-mvvm-proxy-binding/
Our implementation:
The proxies are defined inside XAML like this:
Trying to bind the proxy (inside an item template) always results in a null value:
This worked like a charm as long as we used Noesis 2.2.3. However, since we updated to 3.1.2, these bindings don't seem to work anymore.
I'm not sure what all has changed ever since. It looks like, the DependencyObject of the Binding Proxy never gets created. Are we missing something?
https://code.4noobz.net/wpf-mvvm-proxy-binding/
Our implementation:
Code: Select all
public class BindingProxy : Freezable
{
#if !NOESIS
protected override Freezable CreateInstanceCore()
{
return new BindingProxy();
}
#endif
public object Data
{
get { return (object)GetValue(DataProperty); }
set { SetValue(DataProperty, value); }
}
public static readonly DependencyProperty DataProperty =
DependencyProperty.Register(nameof(Data), typeof(object), typeof(BindingProxy), new UIPropertyMetadata(null));
}
Code: Select all
<Grid Margin="10" >
<Grid.Resources>
<sfx:BindingProxy x:Key="Binding.Root" Data="{Binding}"/>
</Grid.Resources>
<Grid.RowDefinitions>
<RowDefinition Height="40"/>
<RowDefinition Height="25"/>
<RowDefinition/>
</Grid.RowDefinitions>
...
Code: Select all
<Button x:Name="Expander" Grid.Column="0"
sfx:ExpanderHelper.Expanded="{Binding IsExpanded, Mode=OneWay}"
Command="{Binding Data.ToggleExpansionCommand, Source={StaticResource Binding.Root}}"
CommandParameter="{Binding}" Margin="-4"
Visibility="{Binding IsExpandable, Mode=OneWay, Converter={StaticResource BoolToVisibility}}">
...
I'm not sure what all has changed ever since. It looks like, the DependencyObject of the Binding Proxy never gets created. Are we missing something?