导致StackOverflowException的Dependency属性

时间:2015-09-15 13:44:32

标签: xaml windows-phone-8.1

导致StackOverflowException的页面上的示例xaml代码。 如果从第二个元素中删除MyProperty="{Binding ElementName=SourceFlyout}", 没关系。 MyProperty是附属财产。 AdvancedBehavior是最简单的行为类,容易复制错误。 MyProperty是一个空的附加或依赖属性,里面没有逻辑。会发生什么?

<ListPickerFlyout x:Name="SourceFlyout">
    <helpers:XamlExtention.Behaviors>
        <helpers:BehaviorCollection>
            <behaviors:AdvancedBehavior MyProperty="{Binding ElementName=DestinationFlyout}" />
        </helpers:BehaviorCollection>
    </helpers:XamlExtention.Behaviors>
</ListPickerFlyout>

<ListPickerFlyout x:Name="DestinationFlyout">
    <helpers:XamlExtention.Behaviors>
        <helpers:BehaviorCollection>
            <behaviors:AdvancedBehavior MyProperty="{Binding ElementName=SourceFlyout}" />
        </helpers:BehaviorCollection>
    </helpers:XamlExtention.Behaviors>
</ListPickerFlyout>

1 个答案:

答案 0 :(得分:1)

行为AdvancedBehavior不期望通过SourceFlyout绑定到MyProperty,您需要确定MyProperty正常工作所需的实际数据。

相关问题