2013-10-22 3 views
0

코드에서 MultiApplicationBarBehavior.IsVisible 바인딩을 설정하는 방법은 무엇입니까?코드로 appbar의 가시성을 바인딩하는 방법은 무엇입니까?

문제 : 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}}" 
      > 

스플래시 스크린 불투명도 = 0으로 보이는 물체는 여전히 입력을 처리하기 때문에 시인성, 불투명도 바인더 제본한다.

Appbar는 Splashscreen의 Opacity에 바인딩됩니다. 코드 숨김이 전혀 없습니다 (모든 것을 주석 처리했습니다). 그러나 페이지로드 중에 Appbar가 깜박입니다. 그래서 기본적으로 false로 설정하고 나중에 코드로 바인딩하려고합니다. 이 초기화하는 동안 false로 설정 사용자 지정 속성에 바인더 제본 할 때

유일한 경우는, appbar가 깜박하지 않을 때입니다

<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); 
    } 
} 

답변

0

나는 생각하지 않는다 코드에서 바인딩을하는 것이 도움이 될 것입니다. 페이지의 생성자가 실행될 때 (그리고 생성자에서 DataContext가 설정되는 경우) 바인딩 할 값이 false로 설정되었는지 확인 했습니까?
생성자에서 null 인 일부 개체 proeperty에 바인딩하는 경우 바인딩에 FallbackValue = false를 추가 할 수 있습니다.

여기에 다른 해결책을 찾기 코드에서 같은 바인딩을 만드는 방법하지 않는 경우 :

Binding binding = new Binding("Opacity"); 
binding.ElementName = "SplashScreen"; 
binding.Converter = new DoubleToBooleanInversedConverter(); 
multiAppBarBehavior.SetBinding(MultiApplicationBarBehavior.IsVisibleProperty, binding); 

이 (multiAppBarBehavior이 될 것입니다 MultiApplicationBarBehavior 제어 이름)

+0

안녕, 좋은 나중에 볼을 . 업데이트 된 질문. –

+0

페이지의 DataContext가 xaml에 설정되어 있습니까? 그 경우 IsSplashScreenVisible을 설정할 때입니까? –

+0

페이지가 빌드 될 때 IsSplashScreenVisible이 false로 올바르게 설정된 경우 코드를 작성하는 코드가 추가되었습니다. –