How do I use a boolean Value as Trigger

Raymond Osterbrink

I need a VisualStateTrigger which reacts on if a ListView.SelectedIndex > -1

My XAML looks like this:

<Grid Background="{ThemeResource ApplicationPageBackgroundThemeBrush}"
      EntranceNavigationTransitionInfo.IsTargetElement="True">
    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup>
            <VisualState x:Name="wideView">
                <VisualState.StateTriggers>
                    <AdaptiveTrigger MinWindowWidth="960"/>
                </VisualState.StateTriggers>
                <VisualState.Setters>
                    <Setter Target="ListColumn.Width" Value="420"/>
                    <Setter Target="DetailColumn.Width" Value="*"/>
                </VisualState.Setters>
            </VisualState>
            <VisualState x:Name="narrowDetailView">
                <VisualState.StateTriggers>
                    <AdaptiveTrigger MinWindowWidth="0"/>

                </VisualState.StateTriggers>
                <VisualState.Setters>
                    <Setter Target="ListColumn.Width" Value="0"/>
                    <Setter Target="DetailColumn.Width" Value="*"/>
                </VisualState.Setters>
            </VisualState>
            <VisualState x:Name="narrowListView">
                <VisualState.StateTriggers>
                    <AdaptiveTrigger MinWindowWidth="0"/>
                </VisualState.StateTriggers>
                <VisualState.Setters>
                    <Setter Target="ListColumn.Width" Value="*"/>
                    <Setter Target="DetailColumn.Width" Value="0"/>
                </VisualState.Setters>
            </VisualState>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>
    <Grid.ColumnDefinitions>
        <ColumnDefinition x:Name="ListColumn" Width="0"/>
        <ColumnDefinition x:Name="DetailColumn" Width="*"/>
    </Grid.ColumnDefinitions>
    <ListView x:Name="SelectionList"
              Grid.Column="0"/>
    <ListView x:Name="DetailsList"
              Grid.Column="1"/>
</Grid>

When SelectionList SelectedIndex == -1 the narrowListView-Trigger should be chosen, otherwise, the narrowDetailsView-Trigger is the desired one.

Is this possible only in XAML (and if so, what is the most efficient approach), or do I need to solve this in code-behind.

Igor Ralic

WindowsStateTriggers library is your friend.

<VisualState>
    <VisualState.StateTriggers>
        <triggers:CompareStateTrigger Value="{x:Bind someListView.SelectedIndex, Mode=OneWay}" CompareTo="-1" Comparison="GreaterThan" />
    </VisualState.StateTriggers>
<VisualState.Setters>

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

How do I use a Boolean in Python?

How do I print out the value of this boolean? (Java)

How do I use boolean variables in Perl?

How do I check a value in a boolean List?

How do I use FlowRouter.go to trigger the URL to be reloaded

How do I check the Boolean value on eval() or if an arithmetic operation is false?

How do I pass Nullable<Boolean> value to CommandParameter?

How do I use an updated value in useEffect

How do I use where clause in the sql trigger?

How do I use the char value for string?

How do I use elif for multiple boolean options

How do I make an attribute Boolean as [Required] to use with a RadioButtonFor?

How do I use Google assistant to trigger my application

How do I assign a value in numpy with advanced boolean indexing?

How do I use Python to trigger the download of a file from a website?

How can I use the boolean value in the "jump" method?

How do I use a boolean on my model that wraps a string value from the database?

How do I get a boolean value from an input?

How do I get the value of a boolean from a database field?

How do I use a Java MessageFormat choice with a boolean?

How do I insert a Boolean Value into my SQLite Database?

How do I use the REST API to update an Apex Trigger?

How do I use if/else shortcut to print string based on boolean value

How do I change the value of a boolean method in a method?

How do I use Boolean logic within a pyspark dataframe for sets

How do I assign a boolean object to a value?

How do I use system time as a trigger in codesys ladder?

How do I write a PLSQL trigger that increments a value?

How do I print the boolean value?