views:

63

answers:

1

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

A: 

The MethodAccessException is commonly thrown when the public access modifier is missing from a member you want to access. Have you tested the TabTitles property of whatever is held in the "ResourceWrapper" resource? Have the then tested the HomePageTitle property of whatever TablTitles returns?

Note also that if HomePageTitle returns a UIElement you can only place that value once in the visual tree, however my guess is its a string.

AnthonyWJones