[Xwt.Wpf] Fix commit introduced with pull request #440.
The change didn't account for case where widget can be embedded into a native WPF context and thus the Frontend ParentWindow property being never set causing a infinite loop of drawing refresh.
This commit is contained in:
Родитель
c20493b64e
Коммит
43522ad2b2
|
@ -14,6 +14,7 @@ namespace Xwt.WPFBackend
|
|||
: WidgetBackend, ICanvasBackend
|
||||
{
|
||||
#region ICanvasBackend Members
|
||||
bool hasInitialParent;
|
||||
|
||||
public CanvasBackend ()
|
||||
{
|
||||
|
@ -41,10 +42,11 @@ namespace Xwt.WPFBackend
|
|||
{
|
||||
// delay drawing until all parents are registered and we can
|
||||
// get a window which is required for many drawing operations
|
||||
if (Frontend.ParentWindow == null) {
|
||||
if (!hasInitialParent && Widget.GetParentWindow () == null) {
|
||||
QueueDraw ();
|
||||
return;
|
||||
}
|
||||
hasInitialParent = true;
|
||||
|
||||
if (BackgroundColorSet) {
|
||||
SolidColorBrush mySolidColorBrush = new SolidColorBrush ();
|
||||
|
|
|
@ -64,5 +64,18 @@ namespace Xwt.WPFBackend
|
|||
|
||||
throw new InvalidOperationException("Invalid alignment value: " + alignment);
|
||||
}
|
||||
|
||||
public static System.Windows.Window GetParentWindow (this FrameworkElement element)
|
||||
{
|
||||
FrameworkElement current = element;
|
||||
while (current != null) {
|
||||
if (current is System.Windows.Window)
|
||||
return (System.Windows.Window)current;
|
||||
|
||||
current = VisualTreeHelper.GetParent (current) as FrameworkElement;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
|
@ -674,15 +674,7 @@ namespace Xwt.WPFBackend
|
|||
|
||||
private SW.Window GetParentWindow()
|
||||
{
|
||||
FrameworkElement current = Widget;
|
||||
while (current != null) {
|
||||
if (current is SW.Window)
|
||||
return (SW.Window)current;
|
||||
|
||||
current = VisualTreeHelper.GetParent (current) as FrameworkElement;
|
||||
}
|
||||
|
||||
return null;
|
||||
return Widget.GetParentWindow ();
|
||||
}
|
||||
|
||||
public void DragStart (DragStartData data)
|
||||
|
|
Загрузка…
Ссылка в новой задаче