c# - ReactiveUI - Views not rendering properly (or in full) -
i'm in process of starting new project, using reactiveui
, mahapps.metro
. first hurdle i've hit problem of views not showing in entirety. have window
, , in window
have viewmodelviewhost
rxui library. simple container nested view-model. activeitem binding binded view-model of user control, , button
user control visible on screen.
what expect see window
dark gray background , button in middle. see window
default background , button
in middle. not right. if remove button, see nothing on window
, default background.
it seems viewmodelviewhost
showing actual contents of usercontrol , disregarding isn't considered real control, such grids etc.
has come across behaviour before?
<mah:metrowindow x:class="...mainwindow" xmlns:mah="clr-namespace:mahapps.metro.controls;assembly=mahapps.metro" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:rx="clr-namespace:reactiveui;assembly=reactiveui" windowstartuplocation="centerscreen" showtitlebar="false" showclosebutton="false" showmaxrestorebutton="false" showminbutton="false" height="768" width="1024"> <grid horizontalalignment="center" verticalalignment="center"> <rx:viewmodelviewhost viewmodel="{binding activeitem}" /> </grid> </mah:metrowindow> <usercontrol x:class="...nestedview" name="theusercontrol" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" mc:ignorable="d" textoptions.texthintingmode="auto" textoptions.textrenderingmode="auto" d:designheight="768" d:designwidth="1024"> <grid background="darkgray"> <button width="200" height="100" /> </grid> </usercontrol>
this won't reactiveui problem, simple wpf one.
the viewmodelviewhost
centered in window. while usercontrol
has designheight
, designwidth
set, when it's rendered @ runtime automatically size height , width of content - button
.
add verticalcontentalignment="stretch" horizontalcontentalignment="stretch"
viewmodelviewhost
declaration , remove other 2 alignment
attributes (they default stretch) , should stretch contents size of window
while centering item has fixed size.
Comments
Post a Comment