How do I force elements added using window.AttachToDomElement to use relative positioning?
----------------------
I previously posted a question about adding text, html or a custom control to an existing Html element, here:
viewtopic.php?f=4&t=8589
This is working, my problem is, anytime I do this,
Code: Select all
var window = new Window
{
Content = childControl
};
window.AttachToDomElement(Interop.GetDiv(control));
The element gets wrapped in a div with in-line style `position: absolute`, for example:
Code: Select all
<div style="position: absolute; width: 100%; height: 100%; overflow: hidden;"><!--My child control --></div>
I have tried to work around this by setting the child control's Horizontal and Vertical alignment, but that does nothing.
I've tried setting the Window's Horizontal and Vertical alignment, but it just throws an error.
Code: Select all
var window = new Window
{
Content = childControl,
VerticalAlignment = VerticalAlignment.Top,
HorizontalAlignment = HorizontalAlignment.Left
};
System.NullReferenceException: Object reference not set to an instance of an object.
at CSHTML5.Internal.INTERNAL_HtmlDomManager.GetDomElementStyleForModification(Object domElementRef)
at System.Dynamic.UpdateDelegates.UpdateAndExecute2[T0,T1,TRet](CallSite site, T0 arg0, T1 arg1)
at CSHTML5.Internal.INTERNAL_HtmlDomManager.GetFrameworkElementOuterStyleForModification(UIElement element)
at Windows.UI.Xaml.FrameworkElement.INTERNAL_ApplyVerticalAlignmentAndHeight(FrameworkElement frameworkElement, VerticalAlignment newVerticalAlignment)
at Windows.UI.Xaml.FrameworkElement.VerticalAlignment_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
at CSHTML5.Internal.INTERNAL_PropertyStore.OnPropertyChanged(INTERNAL_PropertyStorage storage, Object oldValue, Object newValue)
at CSHTML5.Internal.INTERNAL_PropertyStore.SetSpecificValue(INTERNAL_PropertyStorage storage, KindOfValue kindOfValueToSet, Object newValue)
at Windows.UI.Xaml.DependencyObject.SetLocalValue(DependencyProperty dependencyProperty, Object value)
at Windows.UI.Xaml.DependencyObject.SetValue(DependencyProperty dependencyProperty, Object value)
at Windows.UI.Xaml.FrameworkElement.set_VerticalAlignment(VerticalAlignment value)
The only workaround I can find is to force the entire app to use relative positioning, via a stylesheet, which has adverse side effects
Code: Select all
body * { position: relative !important; } //BAD