Caliburn.Micro ShowPopup - set focus

I'm trying to use Caliburn.Micro (for my first WPF MVVM project) and I'm struggling with getting the WindowManager.ShowPopup method to set focus to the popup screen. Is this possible? The sample HelloWindowManager from Caliburn doesn't do it either, and the documentation is pretty light.

Answers


Ultimately, I was unable to get the ShowPopup method to work as I wanted.

What I did instead was use ShowWindow, and then used the EventAggregator to publish an event when I was showing the window. In the ViewModel for the called View, I subscribed to that event, and set a property on the ViewModel to true (named KeywordEntryActive in this example).

I then use a Style on the Grid that uses a DataTrigger bound to that property to call the FocusManager.FocusedElement method in the View.

<Grid.Style>
    <Style>
        <Style.Triggers>
            <DataTrigger Binding="{Binding KeywordEntryActive}" Value="True">
                <Setter Property="FocusManager.FocusedElement" Value="{Binding ElementName=Command}" />
            </DataTrigger>
        </Style.Triggers>
    </Style>
</Grid.Style>

It seemed less straightforward than I hoped, but I was able to accomplish what I was looking for without sacrificing the separation of ViewModel and View, so I'm satisfied with it at this point. There's been a bit of a learning curve with Caliburn.Micro but so far I've been able to overcome the snags I've run into, and I'm continuing down this path.


Need Your Help

udp client bind

c# sockets udp client bind

I have UDP client chat, which sends messages to the server and get the responses back. I have two threads, one for sending, one for receiving messages. I get the exception with ReceiveFrom() method...

PreparedStatement: How to insert data into multiple tables using JDBC

java sql jdbc prepared-statement

Could somebody tell me whether the first stmt.close(); required in the following JDBC code, for executing two different SQL queries against two different tables?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.