I have a WPF application (Window 1) with a ScrollViewer on it. I have a second window that is apart of the same WPF application, that has a button on it.
When I click the button on the second window, I want it to add an item to the ScrollViewer on the first window.
How can I accomplish this? Sorry if this is vague, I’m not sure how to ask this question.
First, you’ll need a
DispatcherTimerand you’ll have to useStackPanelinstead ofGrid. You’ll also need to declare apublic static boolonWindow1. Then, when the button onWindow2is clicked, theboolis set toTruewhich means to execute a void that will add the object to theStackPanelor theScroll ViewerXAML
Window1.xaml
First, you will need to change
GridtoStackPanel. Assuming that you have aScrollViewerwith the namescrollViewer1, andMargin = "37,36,58,36", You should try the followingChange the following
to
So that you would be able to use a
StackPanelinstead of aGridof a namestackPanelC#
Window1.xaml
Window2.xaml
Thanks,
I hope you find this helpful 🙂