I have 2 UserControl
pages.
In one I have a ListBox
and a "continue" Button
.
I want to pass the list to another UserControl
page after I click "continue" but i can't figure out how to do it (Just found examples for Form
or Window
).
I already found how to move to another page, but not how to pass the data in it. Thanks!
This is my code:
The button in the first Xaml (I have there a ListBox
named lbOne
):
<Button x:Name="button"
Content="Continue"
Grid.Column="2"
Margin="81,0,0,-30"
RenderTransformOrigin="0.184,-1.455"
Height="30" VerticalAlignment="Bottom"
Style="{DynamicResource BaseButtonStyle2}"
Click="button_Click"
Command="NavigationCommands.GoToPage"
CommandParameter="/Pages/NextPage/nextPage.xaml"/>
And this is the list:
ObservableCollection<My_Data> list = new ObservableCollection<My_Data>();
public Home()
{
InitializeComponent();
list.Add(new My_Data("first", "explanation"));
list.Add(new My_Data("second", "explanation"));
list.Add(new My_Data("third", "explanation"));
list.Add(new My_Data("forth", "explanation"));
list.Add(new My_Data("fifth", "explanation"));
lbOne.ItemsSource = list;
}
Edit:
I will just be clear and say i want to share the data in the ListBox and not the ObservableCollection because i add more data to the listbox itself at the entire code (This way: lbOne.Items.Insert(insertAtIndex, dragDropData);
)