0

我的 xaml 中有一些按钮,我想根据某个值动态绑定样式。这一切都很好,但可能有一两秒钟的按钮样式不正确,因为我的应用程序仍在加载。我的应用程序将加载,但我有一个列表视图正在等待从 Web 服务接收一些数据。似乎在绑定列表视图之前不会绑定按钮。

有没有办法在我的按钮上设置“默认”样式,但仍然在运行时绑定我的按钮,而不必为每个按钮设置所有属性?或者为什么我的按钮需要这么长时间才能绑定?我可以优先考虑它们吗?

这是我的按钮...

<Button x:Name="ButtonAll" Click="ButtonAll_Click" Style="{Binding State,Converter={StaticResource ButtonStateConverter},ConverterParameter=All}" Margin="0,0,50,0">All</Button>

这是我的转换器代码...

SampleState state = (SampleState)value;

SampleState param = new SampleState() { Code = (string)parameter, Name = (string) parameter };

if (state == param)
     return App.Current.Resources["TextPrimaryButtonStyle"];
else
     return App.Current.Resources["TextSecondaryButtonStyle"];
4

0 回答 0