【发布时间】:2013-10-22 23:18:05
【问题描述】:
如何在代码中设置 MultiApplicationBarBehavior.IsVisible 绑定?
问题:如果通过xaml绑定,即使绑定值为false也会闪烁。
EDIT1:那么,我要绑定什么?
<mainPivot:SplashScreenControl
Opacity="1"
Name="SplashScreen"
Visibility="{Binding Opacity, ElementName=SplashScreen, Converter={StaticResource DoubleToVisibilityConverter}}"
/>
<cimbalino:MultiApplicationBarBehavior
SelectedIndex="{Binding PivotIndex}"
IsVisible="{Binding Opacity, ElementName=SplashScreen, Converter={StaticResource DoubleToBooleanInversedConverter}}"
>
Splashscreen:可见性绑定到不透明度,因为不透明度=0 的可见对象仍在处理输入。
Appbar 只是绑定到 Splashscreen 的不透明度。根本没有代码隐藏(只是注释掉了所有内容)。但是,appbar 在页面加载期间闪烁。这就是为什么我想将其默认设置为 false 并稍后通过代码绑定。
appbar 不闪烁的唯一情况是绑定到自定义属性时,该属性在初始化期间设置为 false
<cimbalino:MultiApplicationBarBehavior
SelectedIndex="{Binding PivotIndex}"
IsVisible="{Binding IsSplashScreenVisible, Converter={StaticResource BooleanInversedConverter}}"
>
转换器:
public class DoubleToBooleanInversedConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
if (value == null)
return true;
return !((value as double?) > 0);
}
}
【问题讨论】:
标签: c# windows-phone-7 mvvm appbar cimbalino