Align right with center of panel using RelativePanel

Viewed 378

I want to align right of control with center of panel, how can I do that?

Using column definitions does not work.

RelativePanel error: The name 'MiddleSplitter' does not exist in the current context

<Grid x:Name="LayoutRoot">

    <Grid.ColumnDefinitions>
        <ColumnDefinition/>
        <ColumnDefinition x:Name="MiddleSplitter"/> <!--get middle?-->
    </Grid.ColumnDefinitions>

    <VisualStateManager.VisualStateGroups>
        <VisualStateGroup>
            <VisualState>
                <VisualState.StateTriggers>
                    <StateTrigger IsActive="True"/> <!--just for test-->
                </VisualState.StateTriggers>
                <VisualState.Setters>

                    <Setter Target="AppListBox.(RelativePanel.AlignRightWith)" Value="MiddleSplitter"/>

                </VisualState.Setters>
            </VisualState>
        </VisualStateGroup>
    </VisualStateManager.VisualStateGroups>

    <ScrollViewer Grid.ColumnSpan="2">
        <RelativePanel Margin="5">

            <ListBox Name="AppListBox" Height="150" Margin="5"/>

        </RelativePanel>
    </ScrollViewer>
</Grid>

I have to use RelativePanel, this is simplified to only show the control that has this problem (AppListBox), I don't want to use other type of panels.

2 Answers
Related