Saarix
Topic Author
Posts: 7
Joined: 09 Jun 2021, 07:53

Is Parent binding supported?

23 Jun 2021, 11:25

Hello,

recently I've ran into issue with binding commands to a button. I used binding to Parent which works just fine in WPF, but under Unity it is not.
I wanted to ask if this feature is supported, since I couldn't find it here: https://www.noesisengine.com/docs/3.0/G ... nding.html
It says in the documentation that RelativeSource binding should work, so I was curious if Path might be the issue here.
Command="{Binding Parent.DataContext.OpenHomeCommand, RelativeSource={RelativeSource Mode=FindAncestor, AncestorType={x:Type UserControl}}}"
Note: I could always move that command to current DataContext and avoid binding to a parent. Tho I would like to know reasoning behind as to why it is not working this way.

Thanks for any insight on this.
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: Is Parent binding supported?

28 Jun 2021, 11:03

Hi, that kind of binding should work, I just made the following simple test and the result was as expected a Red rectangle:
<Grid
  xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
  xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
  <Grid.Resources>
    <GradientStop x:Key="stop1" Offset="123" Color="Red"/>
    <GradientStop x:Key="stop2" Offset="123" Color="Blue"/>
  </Grid.Resources>
  <Border DataContext="{StaticResource stop1}" HorizontalAlignment="Center" VerticalAlignment="Center">
    <StackPanel DataContext="{StaticResource stop2}">
      <Rectangle Width="300" Height="100">
        <Rectangle.Fill>
          <SolidColorBrush Color="{Binding Parent.DataContext.Color, RelativeSource={RelativeSource AncestorType={x:Type StackPanel}}}"/>
        </Rectangle.Fill>
      </Rectangle>
    </StackPanel>
  </Border>
</Grid>
I will need a bit more of context to that binding to see if there is a situation where this is failing in Noesis, could you please create a ticket in our bugtracker and attach the xamls involving that binding?
 
Saarix
Topic Author
Posts: 7
Joined: 09 Jun 2021, 07:53

Re: Is Parent binding supported?

29 Jun 2021, 11:15

I will post that ticket, sorry for the lack of context here.
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: Is Parent binding supported?

01 Jul 2021, 10:36

Thanks for the detailed report #2055

Who is online

Users browsing this forum: Ahrefs [Bot], Bing [Bot] and 3 guests