ContentControl not properly binding.
I have the following XAML that is working in Unity and in the WebGL build, but not in Android:
(I only put the Background color, width and height in to see what was going on on Android--normally it sizes to the bound control)
I am setting ModalContent to a code-created UserControl in the ViewModel. Under the Unity editor and in WebGL, this works just fine, but in Android, all I get is a red 100 x 100 square.
Any specific reason Android wouldn't be binding this ContentControl properly? The control is obviously there since I see the red background, but it isn't rendering the UserControl like it does in the editor.
BTW, I updated to the latest Noesis 2.2.4 and Unity 2019.2 but that did not fix the problem.
EDIT: I was wrong, this ISN'T working in WebGL. So it only works in the editor, not in any builds. I must be doing something wrong. Anyone know what it could be?
Code: Select all
<Grid Background="Transparent" Visibility="{Binding ModalVisible, Converter={StaticResource BoolToVisConverter}}">
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto" />
<RowDefinition Height="*" />
</Grid.RowDefinitions>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
<ColumnDefinition Width="*" />
</Grid.ColumnDefinitions>
<ContentControl Grid.Row="1" Grid.Column="1" Content="{Binding ModalContent}" Background="Red" Width="100" Height="100"/>
</Grid>
I am setting ModalContent to a code-created UserControl in the ViewModel. Under the Unity editor and in WebGL, this works just fine, but in Android, all I get is a red 100 x 100 square.
Any specific reason Android wouldn't be binding this ContentControl properly? The control is obviously there since I see the red background, but it isn't rendering the UserControl like it does in the editor.
BTW, I updated to the latest Noesis 2.2.4 and Unity 2019.2 but that did not fix the problem.
EDIT: I was wrong, this ISN'T working in WebGL. So it only works in the editor, not in any builds. I must be doing something wrong. Anyone know what it could be?
Re: ContentControl not properly binding.
I was able to work around this by explicitly defining the view in XAML and just dynamically binding the ViewModel to allow be customization. I was planning on using one ContentControl for all "modal" type items, but I can just specify a separate specific view for each one or create a datatemplate. I only have a few different variations.
Still confused as to why this didn't work, but this method works fine.
Still confused as to why this didn't work, but this method works fine.
Re: ContentControl not properly binding.
Question, is that UserControl using a XAML? Because I would say that dependency is not expressed anywhere and you need to do it (for example, attaching the XAML to a public property to a behaviour script). If you don't do that Unity will discard that asset when building the standalone app. We can do this automatically for UserControls, but this is a different scenario.
Re: ContentControl not properly binding.
Yes! The UserControl UI was defined by a XAML. So this is probably a Unity issue. I was just trying to be efficient and host all of my "modal" content in one full-screen transparent grid that centered any bound UserControl. I was just being fooled because it worked in the editor.
Having separate grids for each of my 4 or 5 UserControls is a little extra work, but not enough to worry about. Thanks for the explanation! Noesis acts so much like WPF that I sometimes forget I'm dealing with the particulars of Unity in here.
Having separate grids for each of my 4 or 5 UserControls is a little extra work, but not enough to worry about. Thanks for the explanation! Noesis acts so much like WPF that I sometimes forget I'm dealing with the particulars of Unity in here.
Re: ContentControl not properly binding.
Thanks for your feedback! Can we mark this as solved?
Who is online
Users browsing this forum: Google [Bot] and 69 guests