vaninadisc
Topic Author
Posts: 10
Joined: 10 Mar 2017, 08:23

Codebehind FindName not working in ItemsControl?

19 Apr 2017, 05:57

As the subject says...
 
private void OnInitialized(object sender, EventArgs args)
{
    var but = FindName("Buttony");
    UnityEngine.Debug.Log("but: " + but.ToString());
}
Works just fine if I add the control to a parent xaml as a totally normal control with <myNamespace:ControlName />
But, if I go
<ItemsControl ItemsSource="{Binding Blah}">
    <ItemsControl.ItemsPanel>
        <ItemsPanelTemplate>
            <WrapPanel />
        </ItemsPanelTemplate>
    </ItemsControl.ItemsPanel>
    <ItemsControl.ItemTemplate>
        <DataTemplate>
            <myNamespace:ControlName />
        </DataTemplate>
    </ItemsControl.ItemTemplate>
</ItemsControl>
then FindName returns null.

Any help would be appreciated. Thanks! This is in Unity 5.5.1f1 32b, and Noesis 2.0
 
vaninadisc
Topic Author
Posts: 10
Joined: 10 Mar 2017, 08:23

Re: Codebehind FindName not working in ItemsControl?

19 Apr 2017, 21:40

Ah, oops. Just realized it's the same bug as my other post (viewtopic.php?f=3&t=1064), I guess it applies to both ItemsPanelTemplates and DataTemplates. I put them in a <Border> and it fixed it like last time.

Nevermind!
 
User avatar
sfernandez
Site Admin
Posts: 3250
Joined: 22 Dec 2011, 19:20

Re: Codebehind FindName not working in ItemsControl?

20 Apr 2017, 18:32

Yes, it the same scenario.
It will be fixed in the next release.

Who is online

Users browsing this forum: No registered users and 6 guests