WPF- 데이터 바운드 텍스트 블록의 가시성을 기본적으로 기본값은 무엇입니까?
-
19-09-2019 - |
문제
아래에 정의 된이 텍스트 블록은 다른 컨트롤에서 항목이 선택 될 때까지 Datacontext (따라서 변환기 코드가 실행되지 않기 때문에 Window가 처음로드 될 때를 보여줍니다. EG TreeView).
<TextBlock
Name="tbkDocumentNotFound"
Style="{StaticResource StandardText}"
Margin="4,4,2,0"
TextWrapping="Wrap"
Visibility="{Binding Path=IsDownloaded, Converter={StaticResource docNotFoundVisibilityConverter}, Mode=TwoWay}"
Text="The document could not be found.">
</TextBlock>
그렇다면 Datacontext가 없을 때 IT가 나타나는 것을 어떻게 중지합니까?
감사.
해결책
기본값을 제공하려면 (바인딩 대상을 찾을 수없는 경우 사용) FallbackValue
, 예를 들어:
Visibility="{Binding Path=IsDownloaded, FallbackValue=Collapsed}"
Datacontext가 없을 때 발생해야합니다.
제휴하지 않습니다 StackOverflow