Adding a new IronPython WPF Window to complains "Window is not supported in a WPF project"
Asked Answered
R

1

10

Immediately after adding a brand new, untouched WPF window to my IronPython 2.7 project in VS2013 (with Python Tools for VS 2.0.11016), it tells me "Invalid Markup" in the design window, and the error list shows:

Window is not supported in a Windows Presentation Foundation (WPF) project.

Grid is not supported in a Windows Presentation Foundation (WPF) project.

The XAML window has this innocuous looking code in it:

<Window xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Window1" Height="300" Width="300">
    <Grid>
        
    </Grid>
</Window>

Does Python tools for VS not really support form creation? Did I forget to configure something?

Rights answered 22/3, 2014 at 18:59 Comment(1)
does it compile? are all needed references for WPF added?Miniaturist
R
14

The project was started as an "IronPython Windows Forms Application" rather than an "IronPython WPF Application" so it was missing the relevant references:

  • PresentationCore
  • PresentationFramework
  • WindowsBase

Adding them makes WPF forms functional, or just recreating the project.

If all of those references appear to be in the project, removing/readding some might help. Another user reported he had to do so for 'PresentationFramework'; perhaps there's a couple that have the same name?

Rights answered 22/3, 2014 at 20:5 Comment(2)
For me, I had to check the boxes next to them in "add references"; didn't had to delete them.Serval
For me, removing "PresentationFramework" from References and adding it back solved the problem.Alleyway

© 2022 - 2024 — McMap. All rights reserved.