Search code examples
wpfvb.netlistboxexpander

Listbox with Expanders to another listbox


I'm trying to move an item from expander in listbox (keep the item there) and copy it to another listbox.

<ListBox Name="lbAvailableColumns" Grid.Row="1" Grid.Column="0">
            <Expander Header="Account" Background="Transparent" BorderBrush="{x:Null}"  >
                <StackPanel>
                    <ListBox>
                        <ListBoxItem Content="Account Is Locked Out"/>
                        <ListBoxItem Content="Expiration Date"/>
                        <ListBoxItem Content="Last Lockout Date"/>
                        <ListBoxItem Content="Must Change Password"/>
                        <ListBoxItem Content="Password Age(Days)"/>
                        <ListBoxItem Content="Password Last Changed"/>
                        <ListBoxItem Content="Password Never Expires"/>
                        <ListBoxItem Content="Password Not Required"/>
                        <ListBoxItem Content="Smart Card Required For Logon"/>
                        <ListBoxItem Content="User Cannot Change Password"/>
                        <ListBoxItem Content="Username"/>
                    </ListBox>
                </StackPanel>
            </Expander>
            <Expander Header="Exchange" Background="Transparent" BorderBrush="{x:Null}" />
            <Expander Header="General" Background="Transparent" BorderBrush="{x:Null}"/>
            <Expander Header="Group Membership" Background="Transparent" BorderBrush="{x:Null}"/>
            <Expander Header="Organization" Background="Transparent" BorderBrush="{x:Null}"/>
            <Expander Header="Other" Background="Transparent" BorderBrush="{x:Null}"/>
            <Expander Header="Profile" Background="Transparent" BorderBrush="{x:Null}"/>
            <Expander Header="System" Background="Transparent" BorderBrush="{x:Null}"/>
            <Expander Header="Telephone" Background="Transparent" BorderBrush="{x:Null}"/>
        </ListBox>

I'm trying to do the following, and am having a bit of trouble.

enter image description here

Trying to copy item from the expander listbox, to the visible columns listbox. Any ideas?


Solution

  • From the suggestions of @Ed Plunkett I coded a complete example.

    Complete Example

    Source Code on GitHub