horizontal visibility of silverlight listbox items??

Apr 30 2010 7:08 AM

hi,
 i'm getting problem with listbox.my code is given below.when i select checkbox inside datagrid,next column will display  one linkbutton.on that linkbutton click,it wil display child checkboxes with content just below to that column. on this child checkbox click i have to display selected items into listbox with paren checkbox content,and also need to insert one delete button similar to that row.on that button click i have to remove  the item from listbox.
 
my problem is my delete button is displaying just below to each row.i need to display this in horizontal order.in design also i tried to add columns,then also not working.
if anyone knows plz help me........
private void chkbx_domain_child_Checked(object sender, RoutedEventArgs e)
{
tbldomain selectedRow = dtgrid_domain.SelectedItem as tbldomain;
StackPanel stackpanel1 = ((CheckBox)sender).Parent as StackPanel;
CheckBox c = stackpanel1.Children[0] as CheckBox;
string s = c.Content.ToString();
lstbox_domain_right.Items.Add(selectedRow.domainname +
":" + s);
Button btn_domain_listbxDel = new Button();
btn_domain_listbxDel.Content =
"X";
btn_domain_listbxDel.Height = 20;
StackPanel st = new StackPanel();
st.Orientation =
Orientation.Horizontal;
st.Children.Add(btn_domain_listbxDel);
lstbox_domain_right.Items.Add(st);
btn_domain_listbxDel.Visibility =
Visibility.Visible;
btn_domain_listbxDel.HorizontalAlignment =
HorizontalAlignment.Right;
btn_domain_listbxDel.Click +=
new RoutedEventHandler(btn_domain_listbxDel_Click);
}
void btn_domain_listbxDel_Click(object sender, RoutedEventArgs e)
{
StackPanel stack = ((Button)sender).Parent as StackPanel;
Button b = stack.Children[0] as Button;
indx =
Convert.ToInt32(lstbox_domain_right.SelectedIndex.ToString());
if (indx == -1)
{
MessageBox.Show("Plz select an item to delete...");

}
else
{
lstbox_domain_right.Items.RemoveAt(indx);
b.Visibility =
Visibility.Collapsed;
}
}
in design,
<ListBox Name="lstbox_domain_right" Visibility="Collapsed" Background="#E6E6E6" BorderThickness="0" >

<TextBlock Name="txtblk_domain_lstbx" Text="Domain:" FontWeight="Bold"></TextBlock>
</ListBox>