mdube
Topic Author
Posts: 19
Joined: 23 Aug 2019, 12:14

ActualWidth used in converter is 0 instead of actual width

24 Dec 2021, 18:09

Hi,

This was working fine with 3.0.10, but seems broken with 3.1.2. The code works also fine in Blend, so I assume this is a bug in Noesis introduced between 3.0.10 and now.

I have some decorator used to later get the width of some elements.
<Decorator Grid.ColumnSpan="5" x:Name="RefWidth"></Decorator>
Then binding to 'ActualWidth' with a converter to get the negative value, to move the object to the left of the screen. When I put a breakpoint in the Convert method of the converter, the received value is 0.
<Grid.Resources>
   <Storyboard x:Key="StoryBoardEmailInfo">
       <DoubleAnimation Storyboard.TargetName="GridCreateAccount"
                        Storyboard.TargetProperty="RenderTransform.(TranslateTransform.X)" 
                        To="{Binding ActualWidth, ElementName=RefWidth, Converter={StaticResource NegativeConverter}}" Duration="0:0:0.5">
           <DoubleAnimation.EasingFunction>
               <PowerEase EasingMode="EaseIn"/>
           </DoubleAnimation.EasingFunction>
       </DoubleAnimation>
   </Storyboard>
</Grid.Resources>
I would love to find a workaround until this gets fixed, else I'll have to revert to 3.0.xx

Thanks
 
User avatar
sfernandez
Site Admin
Posts: 2983
Joined: 22 Dec 2011, 19:20

Re: ActualWidth used in converter is 0 instead of actual width

30 Dec 2021, 13:06

Could you please report this issue in our bugtracker?

In the meantime, it should work if you wrap the resources inside a ResourceDictionary node like this:
<Grid.Resources>
  <ResourceDictionary>
    <Storyboard x:Key="StoryBoardEmailInfo">
       <DoubleAnimation Storyboard.TargetName="GridCreateAccount"
                        Storyboard.TargetProperty="RenderTransform.(TranslateTransform.X)" 
                        To="{Binding ActualWidth, ElementName=RefWidth, Converter={StaticResource NegativeConverter}}" Duration="0:0:0.5">
           <DoubleAnimation.EasingFunction>
               <PowerEase EasingMode="EaseIn"/>
           </DoubleAnimation.EasingFunction>
       </DoubleAnimation>
    </Storyboard>
  </ResourceDictionary>
</Grid.Resources>
 
mdube
Topic Author
Posts: 19
Joined: 23 Aug 2019, 12:14

Re: ActualWidth used in converter is 0 instead of actual width

30 Dec 2021, 22:08

I wrapped into a <ResourceDictionary>, but this still doens't work.
 
mdube
Topic Author
Posts: 19
Joined: 23 Aug 2019, 12:14

Re: ActualWidth used in converter is 0 instead of actual width

30 Dec 2021, 22:17

My bad, the converters used in the previous excerpt do work fine, breakpoint placed in the converter code shows 2 calls, one with 0, then one with the actual width. I have multiple use cases on the same xaml page and mistaken some. The code not working is when used in Triggers, where it doesn't reach the breakpoint placed in the converter at all.
            <Grid.Triggers>
                <EventTrigger SourceName="BtnAnonymous" RoutedEvent="Button.Click">
                    <EventTrigger.Actions>
                        <BeginStoryboard x:Name="StoryBoard0">
                            <Storyboard>
                                <DoubleAnimation Storyboard.TargetName="GridSigninButtons"
                                     Storyboard.TargetProperty="RenderTransform.(TranslateTransform.X)" 
                                     To="{Binding ActualWidth, ElementName=RefWidth, Converter={StaticResource NegativeConverter}}" Duration="0:0:0.5">
                                    <DoubleAnimation.EasingFunction>
                                        <PowerEase EasingMode="EaseIn"/>
                                    </DoubleAnimation.EasingFunction>
                                </DoubleAnimation>
                            </Storyboard>
                        </BeginStoryboard>
                    </EventTrigger.Actions>
                </EventTrigger>
            </Grid.Triggers>
 
mdube
Topic Author
Posts: 19
Joined: 23 Aug 2019, 12:14

Re: ActualWidth used in converter is 0 instead of actual width

30 Dec 2021, 22:33

Ok, what worked was to move the Storyboard definition from the EventTrigger to the <Grid.Resources> AND to wrap into <ResourceDictionary>.
 
User avatar
sfernandez
Site Admin
Posts: 2983
Joined: 22 Dec 2011, 19:20

Re: ActualWidth used in converter is 0 instead of actual width

10 Jan 2022, 18:27

Added ticket #2234 to solve this issue.

Who is online

Users browsing this forum: Google [Bot], jayk.techabbot and 36 guests