Page 1 of 1

Codebehind FindName not working in ItemsControl?

Posted: 19 Apr 2017, 05:57
by vaninadisc
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

Re: Codebehind FindName not working in ItemsControl?

Posted: 19 Apr 2017, 21:40
by vaninadisc
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!

Re: Codebehind FindName not working in ItemsControl?

Posted: 20 Apr 2017, 18:32
by sfernandez
Yes, it the same scenario.
It will be fixed in the next release.