hyperlink button default state.

May 4, 2011 at 1:09 PM

Hi , i am using  hyperlinks buttons and navigation framework in calliburn. i have used jetpack style template. the problem is when the screen loads first time my first hyperlink button is not showing as pressed (ActiveLINK). when i navigate to other hyperlinks buttons it works fine. i have used the follwoing  code

[Export(typeof(IShell))]
    public class MainPageViewModel : Conductor<object>, IShell
    {
        private int _SelectedTabIndex;
        [Import]
        public ProjectsViewModel ProjectsVM { get; set; }
        public MainPageViewModel()
        {
            _SelectedTabIndex = 0;
            //LoadScreen();
        }
        protected override void OnActivate()
        {
            LoadScreen();
            base.OnActivate();
        }
 
        public void OpenTab(int nTabIndex, HyperlinkButton hp)
        {
            _SelectedTabIndex = nTabIndex;
            LoadScreen();
            //Make the pressed hyperlink active so that it looks with changed background color.
            StackPanel LinksStackPanel = (StackPanel)hp.Parent;
            foreach (UIElement child in LinksStackPanel.Children)
            {
                HyperlinkButton hb = child as HyperlinkButton;
                if (hb != null)
                {
                    VisualStateManager.GoToState(hb, "InactiveLink", true);
                }
            }
            VisualStateManager.GoToState(hp, "ActiveLink", true);
        }

        public void LoadScreen()
        {
            switch (_SelectedTabIndex)
            {
                case 0:
                    ActivateItem(ProjectsVM);
                    break;
                case 2:
                    ActivateItem(new ProjectTools.ViewModels.ProjectToolsViewModel());
                    break;
                case 3:
                    ActivateItem(new DataManagement.ViewModels.DataManagementViewModel());
                    break;
            }                       
        }
    }

Is there any way that i can set the first hyperlink button as "Activelink" when screen loads the very first time. is there any property in design time to do so ?? 

Here is my xam.

 

 <HyperlinkButton x:Name="lnkProjects" Style="{StaticResource LinkStyle}"         
                                      TargetName="ContentFrame" Content="{Binding Path=ApplicationStrings.HomePageTitle, Source={StaticResource ResourceWrapper}}">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Click">
                            <cal:ActionMessage MethodName="OpenTab">
                                <cal:Parameter Value="0"></cal:Parameter>
                                <cal:Parameter Value="$source" ></cal:Parameter>
                            </cal:ActionMessage>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
             
                </HyperlinkButton>