TitleLinks - Open a new Modern UI Window

May 6, 2013 at 7:58 PM
Edited May 6, 2013 at 7:58 PM
Hi,

Is it possible to open a new modern UI window by clicking on the title links? (And not to load a user control into the current window). A good example would be a settings window with multiple levels of settings.

Thanks

Gordon
Coordinator
May 7, 2013 at 2:41 PM
That requires title links to handle command links (such as is implemented with the ILinkNavigator). That's currently not the case, but I'm working on it.

Related to this thread
Jul 11, 2013 at 8:49 PM
Hi,

Is this possible to do this? It would be good to be able to do this as if it were an ICommand, So that it could be triggered from buttons, double clicks on items in a list view etc.

Cheers

Mark
Sep 5, 2013 at 3:30 PM
I think that this behavior will be very useful for many people, there are some situations when it's better to open a new window instead to navigating, for example to show help or settings.

Is the command handling already implemented? If not, could you give us some hints to implement it? Thank you
Coordinator
Sep 5, 2013 at 3:59 PM
Edited Sep 5, 2013 at 3:59 PM
Not implemented yet. I'm thinking about using the ModernWindow.LinkNavigator to perform navigation (and command handling) for title links. The issue is that the LinkNavigator needs to be aware of the main ModernFrame instance in the ModernWindow to perform page navigation. This behavior can be extended to ModernMenu and ModernTab links as well.

Above and support for a NavigationService is on the top of my mui todo list.
Sep 6, 2013 at 4:29 AM
Thank you very much kozw
Dec 5, 2013 at 4:25 PM
Hi Kozw

Do you know when the release supporting this will be available?

Appreciate the awesome framework!
Sep 13, 2014 at 8:20 PM
I know this is late, but maybe it'll save someone some time.

Let's say I've gone through the excellent "My first Modern UI app" tutorial here and I want to add a title link of "Say Hello" that opens SayHelloView.xaml in a new window.

MainWindow.xaml:
<mui:ModernWindow x:Class="MuiTitleLinkCommandExample.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:mui="http://firstfloorsoftware.com/ModernUI"
        Title="MainWindow" Height="350" Width="525"
        ContentSource="/Page1.xaml">
    <mui:ModernWindow.TitleLinks>
        <mui:Link DisplayName="Say Hello" Source="cmd://sayHello" />
    </mui:ModernWindow.TitleLinks>
    <mui:ModernWindow.MenuLinkGroups>
        <mui:LinkGroup DisplayName="group 1" >
            <mui:LinkGroup.Links>
                <mui:Link DisplayName="link 1" Source="/Page1.xaml" />
                <mui:Link DisplayName="link 2" />
                <mui:Link DisplayName="link 3" />
            </mui:LinkGroup.Links>
        </mui:LinkGroup>
    </mui:ModernWindow.MenuLinkGroups>
</mui:ModernWindow>
MainWindow.xaml.cs:
    public partial class MainWindow : ModernWindow 
    {
        public MainWindow()
        {
            InitializeComponent();
            SayHelloCommand = new RelayCommand(o => SayHello(o));
            LinkNavigator.Commands.Add(new Uri("cmd://sayHello", UriKind.Absolute), SayHelloCommand);
        }

        public RelayCommand SayHelloCommand { get; private set; }

        private void SayHello(object o)
        {
            var wnd = new ModernWindow
            {
                Style = (Style)App.Current.Resources["EmptyWindow"],
                Content = new SayHelloView(),
                SizeToContent = SizeToContent.WidthAndHeight
            };

            wnd.Show();
        }
    }
SayHelloView.xaml:
<UserControl x:Class="MuiTitleLinkCommandExample.SayHelloView"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             mc:Ignorable="d" 
             d:DesignHeight="300" d:DesignWidth="300">
    <Grid>
        <TextBlock FontSize="50" Text="Hello!"/>
    </Grid>
</UserControl>
Nov 6, 2014 at 9:50 AM
Edited Nov 6, 2014 at 9:51 AM
Thanks very much sdenison! That's a great solution there. Also thanks very much kozw for all your hard work.

I've managed to create a title link that opens a context menu with several items that each open a new window when clicked on. Here's an example of that code using sdenison's implementation of it.
    public partial class MainWindow : ModernWindow 
    {
        public MainWindow()
        {
            InitializeComponent();
            SayHelloCommand = new RelayCommand(o => SayHello(o));
            LinkNavigator.Commands.Add(new Uri("cmd://sayHello", UriKind.Absolute), SayHelloCommand);
            OpenToolboxCommand = new RelayCommand(o => OpenToolbox(o));
        }

        public RelayCommand SayHelloCommand { get; private set; }
        public ICommand OpenToolboxCommand { get; set; }

        private void SayHello(object o)
        {
            var contextMenu = new ContextMenu();
            contextMenu.Items.Add(new MenuItem { Header = "Say Hello", Command = OpenToolboxCommand, CommandParameter = new SayHelloView() });
            contextMenu.Items.Add(new MenuItem { Header = "Lorem Ipsum", Command = OpenToolboxCommand, CommandParameter = new LoremIpsum() });
            contextMenu.IsOpen = true;
        }

        private void OpenToolbox(object o)
        {
            var wnd = new ModernWindow
            {
                Style = (Style)App.Current.Resources["BlankWindow"],
                Content = o,
                SizeToContent = SizeToContent.WidthAndHeight
            };
            wnd.Show();
        }
    }