Jamieh
Topic Author
Posts: 44
Joined: 12 Apr 2019, 00:30

ContentControl not properly binding.

03 Sep 2019, 08:08

I have the following XAML that is working in Unity and in the WebGL build, but not in Android:
<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 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?

Tags:
 
Jamieh
Topic Author
Posts: 44
Joined: 12 Apr 2019, 00:30

Re: ContentControl not properly binding.

04 Sep 2019, 05:31

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.
 
User avatar
jsantos
Site Admin
Posts: 2906
Joined: 20 Jan 2012, 17:18
Contact:

Re: ContentControl not properly binding.

04 Sep 2019, 23:50

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.
 
Jamieh
Topic Author
Posts: 44
Joined: 12 Apr 2019, 00:30

Re: ContentControl not properly binding.

06 Sep 2019, 06:53

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.
 
User avatar
jsantos
Site Admin
Posts: 2906
Joined: 20 Jan 2012, 17:18
Contact:

Re: ContentControl not properly binding.

06 Sep 2019, 10:35

Thanks for your feedback! Can we mark this as solved?
 
Jamieh
Topic Author
Posts: 44
Joined: 12 Apr 2019, 00:30

Re: ContentControl not properly binding.

06 Sep 2019, 19:34

Yes, thank you.

Who is online

Users browsing this forum: No registered users and 0 guests