gpt4 book ai didi

c# - 使用绑定(bind)属性在 Metro 风格应用程序中打开应用栏

转载 作者:太空宇宙 更新时间:2023-11-03 20:22:37 24 4
gpt4 key购买 nike

我的主页有应用栏,它在不同页面之间共享。我编写了以下代码以在单击 gridview 项时打开应用栏。

XAML

<AppBar Opened="AppBar_Opened" IsOpen="{Binding IsAppBarOpen}">

后端

private void Clock_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
App.ViewModel.SelectedClock = (Clock)ThemeGridView.SelectedItem;
App.WorldViewModel.IsAppBarOpen = true;
}

private void ThemeGridView_ItemClick(object sender, ItemClickEventArgs e)
{
App.ViewModel.SelectedClock = (Clock)ThemeGridView.SelectedItem;
App.WorldViewModel.IsAppBarOpen = true;
}

世界观模型

private bool _IsAppBarOpen;

public bool IsAppBarOpen
{
get { return _IsAppBarOpen; }
set { base.SetProperty(ref _IsAppBarOpen, value); }
}

GridView XAML

<GridView
Grid.Row="1"
Grid.Column="1"


x:Name="ThemeGridView"
ItemsSource="{Binding Clocks}"
ItemTemplate="{StaticResource WorldClockTemplate}"
SelectionChanged="Clock_SelectionChanged"
SelectionMode="None"
IsItemClickEnabled="True"
ItemClick="ThemeGridView_ItemClick"
>
<GridView.ItemsPanel>
<ItemsPanelTemplate>
<WrapGrid />
</ItemsPanelTemplate>
</GridView.ItemsPanel>
</GridView>

但是当我选择 gridview 项目时,appbar 没有弹出。没有绑定(bind)错误,真是玄乎!

最佳答案

无法绑定(bind) IsOpen 属性 according the msdn :

Note Binding to the IsOpen property doesn't have the expected results because the PropertyChanged notification doesn't occur when the property is set.

关于c# - 使用绑定(bind)属性在 Metro 风格应用程序中打开应用栏,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12582497/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com