0
Windows phone 7 앱 (C#, silverlight, xaml)에서 비어있는 경우 textBlock 자동 숨기기를 만드는 방법은 무엇입니까?Windows phone 7에서 빈 textBlock을 숨기시겠습니까?
WPF와 비슷한 질문이 있지만 실버 라이트에는 적용되지 않는 것으로 알고 있습니다.
당신은 변환기를 사용할 수 있습니다Windows phone 7 앱 (C#, silverlight, xaml)에서 비어있는 경우 textBlock 자동 숨기기를 만드는 방법은 무엇입니까?Windows phone 7에서 빈 textBlock을 숨기시겠습니까?
WPF와 비슷한 질문이 있지만 실버 라이트에는 적용되지 않는 것으로 알고 있습니다.
당신은 변환기를 사용할 수 있습니다:
<TextBlock Visibility="{Binding YourString, Converter={StaticResource LengthConverter}" />
<UserControl.Resources>
<converter:LengthConverter x:Key="LengthToVisibilityConverter" />
</UserControl.Resources>
그런 다음 컨버터는 다음과 같습니다
<TextBlock Visibility="{Binding YourString.Length, Converter={StaticResource LengthConverter}" />
:
이public class LengthToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string text = (string)value;
return text.Length > 0 ? Visibility.Visible : Visibility.Collapsed;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
당신은 직접 텍스트 길이와 결합하여이 약간 청소기를 만들 수 이 경우 변환기는 다음과 같습니다.
,public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
int length = (int)value;
return length > 0 ? Visibility.Visible : Visibilty.Collapsed;
}
여기 컨버터에 대한보다 자세한 정보 http://msdn.microsoft.com/en-us/library/system.windows.data.binding.converter(v=vs.110).aspx
당신이 TextBlock의 또는하지 데이터 바인딩을 사용하고 있습니까? – Kenneth