gpt4 book ai didi

c# - FrameworkPropertyMetadataOptions.AffectsRender 的 .NET 4.5 Windows 应用商店应用程序等效项是什么?

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

首先,我正在使用 Flipview 构建一个 Windows 商店应用程序,并且我创建了一个自定义上下文指示器,类似于您可以在该博客上找到的第一个示例:http://blogs.u2u.be/diederik/post/2012/08/24/A-CXAML-FlipView-Context-Indicator-for-Windows-8.aspx简而言之:我使用依赖属性将我的 flipview 绑定(bind)到我的用户控件。

我的问题:我用于上下文指示器的 flipview 数据绑定(bind)到 DefaultViewModel。由于我从 Web API 获取我的 flipview 中的图像,因此加载页面时 DefaultViewModel 中的集合将为 null。在我成功加载图像后,我的 DefaultViewModel["collection"] 被填充并且 flipview 相应地显示图像。然而,我的上下文指示器保持不变,并且只会在页面再次加载时显示正确的结果。

我的用户控件中的依赖属性如下:

public static readonly DependencyProperty FlipviewProperty =
DependencyProperty.Register("Flipview", typeof(FlipView), typeof(FlipviewIndicator), new PropertyMetadata(null, FlipView_Changed));

private static void FlipView_Changed(DependencyObject d, DependencyPropertyChangedEventArgs e)
{
FlipviewIndicator indicator = d as FlipviewIndicator;
FlipView flipview = (e.NewValue as FlipView);
indicator.ItemsSource = flipview.ItemsSource;
Binding binding = new Binding();
binding.Mode = BindingMode.TwoWay;
binding.Source = flipview;
binding.Path = new PropertyPath("SelectedItem");
indicator.SetBinding(FlipviewIndicator.SelectedItemProperty, binding);
}

我的问题:是否有可能让我的依赖属性通知 UI 我的用户控件需要重新呈现?我知道在 WPF 中使用 FrameworkPropertyMedata.AffectsRender 是可能的,例如:

public static readonly DependencyProperty FlipviewProperty = DependencyProperty.Register("Flipview",typeof(Flipview),typeof(FlipviewIndicator), new FrameworkPropertyMetadata(new Color(), FrameworkPropertyMetadataOptions.AffectsRender));

在 Windows 应用商店应用中,但不再支持 FrameworkPropertyMedata,商店应用中是否有等效项?

提前致谢!

最佳答案

老问题 - 但简短的回答是否定的。 Windows Store Xaml(在 Windows 8.1 中)只有 PropertyMetadata,但是在依赖属性的更改处理程序中,您仍然可以调用 InvalidateMeasure 之一。 , InvalidateArrangeUpdateLayout像在 WPF 中一样适当。

关于c# - FrameworkPropertyMetadataOptions.AffectsRender 的 .NET 4.5 Windows 应用商店应用程序等效项是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14075981/

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