I want to bind the contents of a HyperlinkButton to a resource programmatically, it’t not working. This is the code I have so far:
HyperlinkButton Link1 = new HyperlinkButton();
Link1.Style = Application.Current.Resources["LinkStyle"] as Style;
Link1.NavigateUri = new Uri("/Home", UriKind.Relative);
Link1.TargetName = "ContentFrame";
Binding b = new Binding("TabTitles.HomePageTitle");
b.Source = this.Resources["ResourceWrapper"];
Link1.SetBinding(HyperlinkButton.ContentProperty, b);
I get a MethodAccessException
The
MethodAccessExceptionis commonly thrown when thepublicaccess modifier is missing from a member you want to access. Have you tested theTabTitlesproperty of whatever is held in the “ResourceWrapper” resource? Have the then tested theHomePageTitleproperty of whateverTablTitlesreturns?Note also that if
HomePageTitlereturns aUIElementyou can only place that value once in the visual tree, however my guess is its a string.