我有一個嵌套的gridview。可見性似乎存在問題。在下面的代碼中,OuterCollection和InnerCollection具有HideInUI屬性,我反向確定可見性(例如,如果爲true,隱藏)。嵌套的GridView可見性無法正常工作
但是,在第二個HideInUI中,如果第一個項目被隱藏,它似乎隱藏了其他所有內容。
<GridView x:Name="GridView_Outer"
InnerCollectionsSource="{Binding Path=OuterCollection}">
<GridView.InnerCollectionTemplate>
<DataTemplate>
<StackPanel Visibility="{Binding Path=HideInUI, Converter={StaticResource InverseBooleanToVisibilityConverter}}">
<Button Content="{Binding Path=Title}"
IsEnabled="False"
Style="{StaticResource CategoryButton}"/>
<GridView x:Name="GridView_Inner"
InnerCollectionsSource="{Binding Path=InnerCollection}">
<GridView.InnerCollectionTemplate>
<DataTemplate>
<Button Width="120"
Command="{Binding ElementName=GridView_Outer, Path=DataContext.SelectPaymentTypeCommand}"
CommandParameter="{Binding Path=PaymentAmountTypeID}"
Content="{Binding Path=ScreenTitle}"
Visibility="{Binding Path=HideInUI, Converter={StaticResource InverseBooleanToVisibilityConverter}}">
</Button>
</DataTemplate>
編輯
很抱歉的混亂。但是會發生什麼。
Ex。類別1具有項目1,項目2,項目3.如果項目1中的HideInUI爲true,則Item2和Item3也會隱藏。但是,如果項目2或項目3是HideInUI,它可以正常工作。我似乎無法找出原因。
因此,您隱藏了嵌套在其中的第二個(按鈕)的父級(StackPanel),因此如果您隱藏父級,則兒童的可見性也會崩潰,這是預期的行爲。 –