I seem to have guessed the problem, if I bind directly to ConfigManager.RepositoryConfig.RepositoryUrl
using the x:Static
syntax, then it updates automatically, if I reference it in the Code-Behind, it doesn't.
How do I get a property in wpf that references a property in a static class to implement notifications?

CodingNinja
96
Reputation points
Why CurrentRepositoryUrl
does not receive the change when ConfigManager.RepositoryConfig.IsConfigured
changes.
XAML
<TextBlock Text="{Binding CurrentRepositoryUrl, Mode="OneWay"}"
CSharp
// Code-Behind
[AddINotifyPropertyChangedInterface] // Fody AOP.
public partial class MainWindow : Window
{
public string CurrentRepositoryUrl
{
get
{
if (!ConfigManager.RepositoryConfig.IsConfigured)
{
Dispatcher.Invoke(() => hypCurrentRepository.ToolTip = "Go to Config Page.”");
return "Repo Not Configured.";
}
Dispatcher.Invoke(() => hypCurrentRepository.ToolTip = "View Repo...");
return ConfigManager.RepositoryConfig.RepositoryUrl;
}
}
}
public static ConfigManager
{
public static RepositoryConfig RepositoryConfig { get; private set; }
}
[AddINotifyPropertyChangedInterface] // Fody AOP.
public RepositoryConfig
{
public bool IsConfigured { get; set; }
public string RepositoryUrl { get; set; }
}
Developer technologies | Windows Presentation Foundation
2,855 questions
Developer technologies | XAML
857 questions
2 answers
Sort by: Most helpful
-
CodingNinja 96 Reputation points
2021-10-28T11:38:27.98+00:00 -
CodingNinja 96 Reputation points
2021-10-29T12:32:11.727+00:00 I don't mind using
x:Static
syntax, myCode-Behind
properties don't have to refer toConfigManager
.
If I do need to, I will reset the value of the property rather than referencing it using a read-only property.