0
我試圖爲我的問題搜索解決方案,但似乎找不到一個解決方案。在數據綁定上實現可見性轉換器
這裏是我的代碼:
<Border Height="24" Margin="25,5" Background="Black" Grid.Column="1" Grid.Row="1" Visibility="{Binding ElementName=tb_SRNB, Path=Text, Converter={StaticResource srVisibility}}">
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center">
<TextBlock Text="SERVICE ROAD" VerticalAlignment="Center" FontSize="10" FontWeight="SemiLight" Foreground="White"/>
<Border Width="6"/>
<Border Background="{Binding ElementName=tb_SRNB, Path=Text, Converter={StaticResource myBorderColorConverter2}}" Grid.Column="1">
<TextBlock x:Name="tb_SRNB" Text="{Binding status.north_bound.service_road_status}" Grid.Column="1" Margin="5,0" HorizontalAlignment="Center" Foreground="White" VerticalAlignment="Center" FontSize="10" FontWeight="SemiLight"/>
</Border>
</StackPanel>
</Border>
而且我有這個資源:
<local:VisibilityController x:Key="srVisibility"/>
而且我VisibilityController:
public object Convert(object value, Type targetType, object parameter, string language)
{
string itemVal = value as String;
if (itemVal.Equals("NA"))
return Visibility.Visible;
else
return Visibility.Collapsed;
}
所以基本上,我想這條邊界崩潰當文本(tb_SRNB)是「NA」但除非可見。
Tnx。
你可以/應該刪除你的問題(和這個答案)。 – WiredPrairie