- SideEffects
- Posts: 2
- Joined:
DependencyObject as Binding Proxy not working since update from 2.2.3 to 3.1.2
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?
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: DependencyObject as Binding Proxy not working since update from 2.2.3 to 3.1.2
I think this could be related to this other post: viewtopic.php?f=3&t=2500
If you wrap your proxy definition in a ResourceDictionary node does it work?
If you wrap your proxy definition in a ResourceDictionary node does it work?
Code: Select all
<Grid.Resources>
<ResourceDictionary>
<sfx:BindingProxy x:Key="Binding.Root" Data="{Binding}"/>
</ResourceDictionary>
</Grid.Resources>
- SideEffects
- Posts: 2
- Joined:
Re: DependencyObject as Binding Proxy not working since update from 2.2.3 to 3.1.2
Wrapping it inside a <ResourceDictionary> did the trick! Now the bindings are working again.
Thank you for the prompt reply!
Thank you for the prompt reply!
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: DependencyObject as Binding Proxy not working since update from 2.2.3 to 3.1.2
Added ticket #2234 to solve this issue.
Re: DependencyObject as Binding Proxy not working since update from 2.2.3 to 3.1.2
Could this be a same bug? If so, how can I fix it?I think this could be related to this other post: viewtopic.php?f=3&t=2500
If you wrap your proxy definition in a ResourceDictionary node does it work?Code: Select all<Grid.Resources> <ResourceDictionary> <sfx:BindingProxy x:Key="Binding.Root" Data="{Binding}"/> </ResourceDictionary> </Grid.Resources>
-
sfernandez
Site Admin
- Posts: 2984
- Joined:
Re: DependencyObject as Binding Proxy not working since update from 2.2.3 to 3.1.2
No, as mentioned in that post it is a problem of how we expose that multiple inheritance to Noesis.Could this be a same bug? If so, how can I fix it?
Who is online
Users browsing this forum: No registered users and 85 guests