none
display button when listbox clicked RRS feed

  • Question

  • hi, can anybody explain on what functions i should use or give me a simple example on how to pop up 3 buttons stack vertically on the right side of a page when the user click on the listbox which is on the page. How should i write it using C# or the code behind?
    Thanks in advance
    Thursday, December 27, 2007 7:31 AM

Answers

  • Is this it?

     

    <Page x:Class="Test.Page1"

    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"

    Title="Page1">

    <Grid>

    <ListBox x:Name="list" VerticalAlignment="Top" HorizontalAlignment="Left" GotKeyboardFocus="listgotfocus">

    <TextBlock Text="Item 1"/>

    <TextBlock Text="Item 2"/>

    <TextBlock Text="Item 3"/>

    </ListBox>

    <StackPanel x:Name="stack" VerticalAlignment="Top" HorizontalAlignment="Right" Visibility="Hidden">

    <Button Content="Button 1"/>

    <Button Content="Button 2"/>

    <Button Content="Button 3"/>

    </StackPanel>

    </Grid>

    </Page>

     

    using System;

    using System.Collections.Generic;

    using System.Linq;

    using System.Text;

    using System.Windows;

    using System.Windows.Controls;

    using System.Windows.Data;

    using System.Windows.Documents;

    using System.Windows.Input;

    using System.Windows.Media;

    using System.Windows.Media.Imaging;

    using System.Windows.Navigation;

    using System.Windows.Shapes;

    namespace Test

    {

    /// <summary>

    /// Interaction logic for Page1.xaml

    /// </summary>

    public partial class Page1 : Page

    {

    StackPanel stck;

    ListBox lst;

    public Page1()

    {

    InitializeComponent();

    lst = (ListBox)this.FindName("list");

    stck = (StackPanel)this.FindName("stack");

    }

    protected void listgotfocus(object sender, KeyboardFocusChangedEventArgs e)

    {

    stck.Visibility = Visibility.Visible;

    }

    }

    }

    Thursday, December 27, 2007 11:08 AM