I've created a basic Metro App for Win 8 using Visual Studio 11 Ultimate in C#.
The problem here is that I want to display text that dynamically changes with certain events. An example would be an app where a number is displayed on the screen and increments by 1 whenever the mouse is clicked.
I've using XAML binding to a data structure I've created which does get the values I need to display, but the problem is that as those values change, the numbers that display on the GUI do not change.
How do I bind my XAML to data that dynamically changes so that the XAML display on the GUI changes as well?
Thanks for the help!
-- edit --
I've implemented the INotifyPropertyChanged interface, but now I'm receiving an Exception from this line of code:
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
Here is the Exception information:
The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))
To check for Windows 8.1 updates, click Start > Control Panel > System and Security > Windows Update > Check for Updates. The window will show any available updates. If there are available updates, click on Install updates and follow the instructions.
No. Support for Windows 8.1 is discontinued, but the software will continue to function. However, after January 10, 2023, your computer running Windows 8.1 will no longer receive security updates.
Windows 8 operating system introduced major changes over its predecessor operating system Windows 7. Windows 8 has a different GUI which is also designed for tablets, mobile devices, USB 3.0 support, Windows Store in order to download and install applications from a centralized market place, ARM processor support, etc.
Make sure your "data structure" you're binding to (properly) implements INotifyPropertyChanged and invokes the PropertyChanged event when you want to notify the UI of a change.
This is the interface that allows the xaml layer to know when values change in the bound data, and update accordingly.
Edit in response to new information:
The application called an interface that was marshalled for a different thread. (Exception from HRESULT: 0x8001010E (RPC_E_WRONG_THREAD))
This suggests you're raising the property changed from a separate thread, which will potentially cause issues. You may need to marshal this back to the main thread using CoreDispatcher.RunAsync. For details, see this thread.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With