I’m using pyrevit, and my WPF form is not being displayed (no error appears on the screen). The XAML layout is defined inline as a string. Interestingly, in another form where the XAML layout is also defined inline, the form is displayed correctly!?
# -*- coding: UTF-8 -*-
from pyrevit import forms
import wpf, clr
clr.AddReference("PresentationFramework")
clr.AddReference("System.Xml")
clr.AddReference("PresentationCore")
clr.AddReference("System.Windows")
from System.IO import StringReader
from System.Windows.Markup import XamlReader
from System.Windows import Window
from pyrevit.forms import WPFWindow
class Time(Window):
LAYOUT = '''
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="450" Width="800">
<Grid >
</Grid>
</Window>'''
def __init__(self):
wpf.LoadComponent(self, StringReader(Time.LAYOUT))
self.ShowDialog()