To make this work, consider making Page an InnerClass of component

I receive the following error for the code piece below.

Error : 'cardImage' declared in SwipeCardsPage.ux(25) is a member of 'Card' and cannot be accessed from 'SwipeCardsPage'. To make this work, consider making 'SwipeCardsPage' an ux:InnerClass of 'Card'. ?: Error : Object reference not set to an instance of an object

<Page ux:Class="SwipeCardsPage">
  <Router ux:Dependency="router"/>
  <JavaScript File="SwipeCardsPage.js"/>

  <Rectangle ux:Name="bgPanel" Width="100%" Height="65%" Alignment="Bottom" Layer="Background">
    <SolidColor ux:Name="trackFill" Color="#ffffff"/>
  </Rectangle>

  <Panel ux:Name="CardActionButtons" Alignment="Top" Y="18%" Opacity="0">
    <StackPanel Alignment="Center">
      <Clicked>
          <Set bgPanel.Height="0"/>
          <Set cardImage.Height="0"/>
      </Clicked>

      <Panel Width="60" Height="60">
        <Circle Color="#013eaa"/>
      </Panel>
    </StackPanel>
  </Panel>

  <Panel ux:Class="Card" Opacity="0.8">
    <Panel ux:Name="topPanel" Width="80%" Height="32%" Alignment="Top" Margin="0,80,0,0">
      <Rectangle ux:Name="topPanelRect" Layer="Background">
        <ImageFill ux:Name="cardImage" File="{item.image}" StretchMode="UniformToFill" WrapMode="ClampToEdge"/>
      </Rectangle>
    </Panel>
  </Panel>

  <Panel ux:Name="cardContainer">
    <PageControl InactiveState="Unchanged" Transition="None">
        <NavigationMotion GotoEasing="QuadraticOut" GotoDuration="0.3"/>
        <Each Items="{pagesView}">
              <Panel ux:Name="cardPanel">
                  <Card />
          </Panel>
        </Each>
    </PageControl>

    <SwipeGesture ux:Name="swipe" Direction="Down" Type="Active"/>
    <SwipingAnimation Source="swipe">
      <Move Target="bgPanel" Y="180" Duration="0.5"/>
      <Change CardActionButtons.Opacity="1" Duration="0.5"/>
    </SwipingAnimation>

    <WhileInactive Threshold="0.2">
      <SetSwipeActive Target="swipe" Value="false"/>
    </WhileInactive>
  </Panel>
</Page>

I can see that why it’s happening but I couldn’t find a proper way to animate cardImage when a card action button is clicked.
You may suggest to put CardActionButtons panel into Card panel but it might affect some other animations in the page that I removed for now so I prefer keep it as it is if it’s possible.

Could you advise me how I can animate the cardImage (for now I just set the height but there could be some advanced animations) in the current structure?

Could you please post a complete reproduction? Otherwise this code doesn’t make much sense.

I’m reading it so that your CardActionButtons wants to call out to a single cardImage, while in reality there’s as many cardImage instances as there are items in your pagesView. Which page / instance of the cardImage do you think you’re referring to then…?

Now, if you’re trying to implement a global “do / do not show images” switch on top of your PageControl, you could use a global WhileTrue, and feed it to your pages as a property or dependency.

So maybe we can start with that complete reproduction, and an explanation of what it is that you’re trying to make?

<Page ux:Class="SwipeCardsPage">
  <Router ux:Dependency="router"/>
  <JavaScript File="SwipeCardsPage.js"/>
  <Activated>
    <Callback Handler="{initPage}"/>
  </Activated>

  <Grid ColumnCount="2" Height="20" Alignment="Top" Margin="20">
    <Text Value="MENU" Color="#fff" Alignment="Left"/>
    <Text Value="ADD" Color="#fff" Alignment="Right"/>
  </Grid>

  <Rectangle ux:Name="bgPanel" Width="100%" Height="65%" Alignment="Bottom" Layer="Background">
    <SolidColor ux:Name="trackFill" Color="#ffffff"/>
  </Rectangle>

  <Panel ux:Name="CardActionButtons" Alignment="Top" Y="18%" Opacity="0">
    <StackPanel Alignment="Center">
      <Clicked>
        <Set cardImage.Y="0"/>
      </Clicked>
      <Panel Width="60" Height="60">
        <Image ux:Name="icon" StretchMode="Uniform" Width="50" Alignment="Center" Color="#FFF" File="../Assets/Icons/contactless.png"/>
        <Circle Color="#013eaa"/>
      </Panel>
      <Panel>
        <Text FontSize="16" Color="#fff" Font="RobotoThin" Margin="0,10,0,0">Pay in-Store</Text>
      </Panel>
    </StackPanel>
  </Panel>

  <Panel ux:Class="Card" Opacity="0.8">
    <Scaling ux:Name="pageScaling" Factor="0.90"/>

    <ActivatingAnimation>
      <WhileActive Threshold="0.5">
        <Callback Handler="{clearTransactions}"/>
      </WhileActive>

      <Change this.Opacity="1" Duration="0.5"/>
      <Change pageScaling.Factor="1" Duration="0.5"/>
    </ActivatingAnimation>

    <EnteringAnimation Scale="0.5">
      <Move X="-1.75" RelativeTo="ParentSize" Duration="0.5"/>
    </EnteringAnimation>
    <ExitingAnimation Scale="0.5">
      <Move X="1.75" RelativeTo="ParentSize" Duration="0.5"/>
    </ExitingAnimation>
    <Deactivated>
      <Callback Handler="{getTransactions}" Delay="0.5"/>
    </Deactivated>

    <Panel ux:Name="topPanel" Width="80%" Height="32%" Alignment="Top" Margin="0,80,0,0">
      <Rectangle ux:Name="topPanelRect" Layer="Background">
        <ImageFill  ux:Name="cardImage" File="{item.image}" StretchMode="UniformToFill" WrapMode="ClampToEdge"/>
      </Rectangle>
    </Panel>
  </Panel>

  <DockPanel ux:Class="CardDetail">
    <ActivatingAnimation>
      <Change this.Opacity="1" Duration="0.5"/>
    </ActivatingAnimation>
    <EnteringAnimation>
      <Move X="-1" RelativeTo="ParentSize" Duration="0.5"/>
    </EnteringAnimation>
    <ExitingAnimation>
      <Move X="1" RelativeTo="ParentSize" Duration="0.5"/>
    </ExitingAnimation>

    <Panel ux:Class="Tab" ClipToBounds="false" Margin="0,0,0,4">
      <string ux:Property="Text"/>
      <Text Value="{ReadProperty Text}" Color="#171859" Alignment="Center"/>
    </Panel>
    <Text ux:Class="WelcomeText" FontSize="30" Alignment="Center"/>
    <Rectangle ux:Name="indicator" LayoutMaster="transactionsTab" Alignment="Bottom" Height="4" Color="#6c7a89">
      <LayoutAnimation>
        <Move RelativeTo="WorldPositionChange" X="0.2" Duration="0.2" Easing="BackIn"/>
      </LayoutAnimation>
    </Rectangle>

    <Grid ColumnCount="2" Height="50">
      <Panel ux:Name="transactionsTab" HitTestMode="LocalBoundsAndChildren">
        <Clicked>
          <Set navigation.Active="transactionsPage"/>
        </Clicked>
        <Tab Text="Transactions"/>
      </Panel>
      <Panel ux:Name="settingsTab" HitTestMode="LocalBoundsAndChildren">
        <Clicked>
          <Set navigation.Active="settingsPage"/>
        </Clicked>
        <Tab Text="Settings"/>
      </Panel>
    </Grid>

    <PageControl ux:Name="navigation">
      <Panel ux:Name="transactionsPage" Alignment="Bottom" Height="44%">
        <WhileActive Threshold="0.8">
          <Set indicator.LayoutMaster="transactionsTab"/>
        </WhileActive>
        <aira.Loader Working="{isTransactionsLoading}" SpinColor="#000"/>

        <ScrollView SnapMinTransform="false">
          <DockPanel>
            <StackPanel ItemSpacing="0">
              <Each Items="{transactions}">
                <Grid ux:Name="grid" RowCount="1" Columns="3*,2*" Clicked="{select}" Background="#fff" Padding="20">
                  <Panel>
                    <StackPanel Alignment="CenterLeft">
                      <Text Value="{merchantName}" Margin="0,0,0,5"/>
                      <Text Value="{date}" Opacity="0.6"/>
                    </StackPanel>
                  </Panel>
                  <Text Value="{amount}" FontSize="35" Alignment="Right"/>
                  <AddingAnimation>
                    <Move RelativeTo="Size" Y="800" Duration="0.5" DelayBack="{i/10}"/>
                  </AddingAnimation>
                </Grid>
              </Each>
            </StackPanel>
          </DockPanel>
        </ScrollView>
      </Panel>
      <Panel ux:Name="settingsPage" Alignment="Bottom" Height="60%">
        <WhileActive Threshold="0.5">
          <Set indicator.LayoutMaster="settingsTab"/>
        </WhileActive>
        <WelcomeText>Welcome to Page 2</WelcomeText>
      </Panel>
    </PageControl>
  </DockPanel>

  <Panel ux:Name="cardContainer">
    <PageControl InactiveState="Unchanged" Transition="None">
      <NavigationMotion GotoEasing="QuadraticOut" GotoDuration="0.3"/>
      <Each Items="{pagesView}">
        <DockPanel ux:Name="cardPanel">
          <Card/>
          <CardDetail/>
        </DockPanel>
      </Each>
    </PageControl>

    <SwipeGesture ux:Name="swipe" Direction="Down" Type="Active"/>
    <SwipingAnimation Source="swipe">
      <Move Target="cardContainer" Y="0.5" RelativeTo="Size" Duration="0.8"/>
      <Move Target="bgPanel" Y="180" Duration="0.5"/>
      <Change CardActionButtons.Opacity="1" Duration="0.5"/>
    </SwipingAnimation>

    <WhileInactive Threshold="0.2">
      <SetSwipeActive Target="swipe" Value="false"/>
    </WhileInactive>
  </Panel>
</Page>

This is the whole piece. You’re correct I need to specify which card’s image that I’d like to animate. However, I’m not sure how to get the active card on the page when the button is clicked.

Well is it really only the card on the active page that you want to affect? If so, your action buttons should reside on each separate page.

If it’s global, then you don’t need to target each individual card at all, but a global WhileTrue, like I suggested in the post above.

Alright, here’s something that we call a complete, minimal reproduction, and it explains the thinking behind what I was saying in my last two posts. Hope that looking at some code will put things in the right perspective:

<App>
    <JavaScript>
    var Observable = require("FuseJS/Observable");
    // list of our pages
    var pages = [
        {title: "Page One", description: "this is description for page 1", color: "#18f"},
        {title: "Page Two", description: "this is description for page 2", color: "#f81"},
        {title: "Page Three", description: "this is description for page 3", color: "#f18"}
    ];
    // a global observable boolean that stores the state for description visibility (opacity actually in this case)
    var hideDescriptions = Observable(false);
    // a function to toggle that state
    function toggleHideDescriptions() {
        hideDescriptions.value = ! hideDescriptions.value;
    }
    // make things available to UX
    module.exports = {
        pages: pages,
        hideDescriptions: hideDescriptions,
        toggleHideDescriptions: toggleHideDescriptions
    };
    </JavaScript>

    <!-- the page class -->
    <Panel ux:Class="MyPage">
        <!-- a boolean property that is passed in for the instance from parent scope -->
        <bool ux:Property="HideDescriptions" />
        <!-- when the property above changes the value to true, change description opacity -->
        <WhileTrue Value="{ReadProperty HideDescriptions}">
            <Change theDescription.Opacity="0" />
        </WhileTrue>
        <!-- and here is the content for the page -->
        <StackPanel Alignment="Center" ItemSpacing="16">
            <Text Value="{title}" TextColor="#fff" TextAlignment="Center" />
            <Text ux:Name="theDescription" Value="{description}" TextColor="#fff" TextAlignment="Center" />
        </StackPanel>
        <Rectangle Color="{color}" />
    </Panel>

    <DockPanel>
        <Panel Dock="Top" Height="56" Color="#000">
            <!-- just a label for the button, the label of which changes depending on what the global visibility state is -->
            <WhileTrue Value="{hideDescriptions}">
                <Change theLabel.Value="Show Descriptions" />
            </WhileTrue>
            <Text ux:Name="theLabel" Value="Hide Descriptions" TextColor="#fff" Alignment="Center" />
            <!-- and it calls the toggling function -->
            <Clicked>
                <Callback Handler="{toggleHideDescriptions}" />
            </Clicked>
        </Panel>
        <PageControl>
            <Each Items="{pages}">
                <!-- finally, here is how we pass the property -->
                <MyPage HideDescriptions="{hideDescriptions}" />
            </Each>
        </PageControl>
    </DockPanel>
</App>