0

I have other-window.xaml file and trying to open this from window.xaml on button click. How did it without code-behind?

2
  • Why do you want to do this? Just because you have no code-behind does not mean your code is of a high quality. Are you trying to ensure it can be unit tested? designed via Expression Blend? Are you following MVVM? Commented Apr 4, 2012 at 9:20
  • I am following MVVM. My code-behind in C#, view model and program model in F#. It seems to me wrong create a View element(such as window) in code-behind and set its properties from code-behind when all other View components in xaml-files. Commented Apr 4, 2012 at 9:47

1 Answer 1

2

You could define the window as a non-shared resource and write an Interactivity TriggerAction that resolves the resource and calls Show on the window. That action can then be used in the combination with an Interactivity EventTrigger on Click.

Sign up to request clarification or add additional context in comments.

4 Comments

+1 Yep - basically it's a whole heck of a lot of work. Just write a bit of code-behind, it really does not harm!
@ColinE: Wouldn't consider it that much work, just one new class with about three lines of imperative code.
Not bad, It would be helpful to see a simple example
@psct: Actually it's a bit more complicated, you would need an IServiceProvider to resolve a StaticResource reference, and you cannot create a reference directly because it will be resolved once and when the window is closed you cannot reopen it so you get an exception. Right now i cannot investigate this further but i may try later.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.