realesmedia
Topic Author
Posts: 85
Joined: 18 May 2016, 10:26

NoesisApp :: DataTrigger does not work correctly

04 Sep 2019, 17:46

Hi

Noesis 2.2.4
<PreviewProjectsControl
    x:Class="PreviewProjectsControl"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:ei="http://schemas.microsoft.com/expression/2010/interactions"
    xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    x:Name="dialog">

    <i:Interaction.Triggers>
        <ei:DataTrigger
            Binding="{Binding Projects.State}"
            Comparison="NotEqual"
            Value="{x:Static ProjectMenuState.Preview}">
            <ei:ChangePropertyAction PropertyName="Visibility" Value="Hidden" />
        </ei:DataTrigger>
    </i:Interaction.Triggers>
    
    </PreviewProjectsControl>
value Prjoects.State = ProjectMenuState::Preview;

Initialize Control...

PropertyChangedTrigger::OnPostInit() -> NoesisApp::DataTrigger::Compare() -> return true

NoesisApp::DataTrigger::mBinding = 0;
NoesisApp::DataTrigger::mValue = value;
NoesisApp::DataTrigger::Copare() return true !!!!

trigger falsely triggered; Action called "Visibility" property set to "Hidden"

I added a comparison to zero at the beginning of the function:

if (mBinding == 0 || mValue == 0 || mComparator == 0) return false;

This works correctly, but you have this check inside the function. did you intentionally do that? or is it a mistake?
bool NoesisApp::DataTrigger::Compare()
{
    if (mBinding == 0 || mValue == 0 || mComparator == 0) return false;
    
    if (GetAssociatedObject() != 0)
    {
        if (mComparison == ComparisonConditionType_Equal)
        {
            return BaseObject::Equals(mBinding, mValue);
        }
        else if (mComparison == ComparisonConditionType_NotEqual)
        {
            return !BaseObject::Equals(mBinding, mValue);
        }
        else
        {
            if (mBinding == 0 || mValue == 0 || mComparator == 0)
            {
                return false;
            }
            return mComparator->Evaluate(mBinding, mComparison, mValue);
        }
    }
    return false;
}

Tags:
 
realesmedia
Topic Author
Posts: 85
Joined: 18 May 2016, 10:26

Re: NoesisApp :: DataTrigger does not work correctly

04 Sep 2019, 18:09

Understood, I need to do two triggers:
    <i:Interaction.Triggers>
        <ei:DataTrigger
            Binding="{Binding Projects.State}"
            Comparison="NotEqual"
            Value="{x:Static ProjectMenuState.Preview}">
            <ei:ChangePropertyAction PropertyName="Visibility" Value="Hidden" />
        </ei:DataTrigger>
        <ei:DataTrigger
            Binding="{Binding Projects.State}"
            Comparison="Equal"
            Value="{x:Static ProjectMenuState.Preview}">
            <ei:ChangePropertyAction PropertyName="Visibility" Value="Visible" />
        </ei:DataTrigger>
    </i:Interaction.Triggers>
 
User avatar
jsantos
Site Admin
Posts: 2899
Joined: 20 Jan 2012, 17:18
Contact:

Re: NoesisApp :: DataTrigger does not work correctly

04 Sep 2019, 23:46

Thanks for the feedback! Marking this as solved.

Who is online

Users browsing this forum: No registered users and 0 guests