我在WPF中有以下代码:
<Grid Visibility="{Binding suma,Converter={StaticResource IsItMyTable2}}" HorizontalAlignment="Stretch" Width="Auto" Height="28" VerticalAlignment="Top" Margin="40,0">
<Grid.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="{DynamicResource gridUkupnoG1Color}" Offset="0"/>
<GradientStop Color="{DynamicResource gridUkupnoG2Color}" Offset="1"/>
</LinearGradientBrush>
</Grid.Background>
<Label Content="{Binding suma}" Foreground="White" FontWeight="Bold" HorizontalContentAlignment="center" Padding="3,3,10,3" BorderBrush="#FFFF0404" BorderThickness="1"></Label>
</Grid>
我在vb.net中有以下代码:
Imports System.Globalization
Public Class IsItMyTable2
Implements IValueConverter
Private Function IValueConverter_Convert(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.Convert
If value > 0 Then Return Visibility.visible
Return Visibility.Collapsed
End Function
Private Function IValueConverter_ConvertBack(value As Object, targetType As Type, parameter As Object, culture As CultureInfo) As Object Implements IValueConverter.ConvertBack
If CBool(value) Then Return "Y"
Return "N"
End Function
End Class
问题是我需要将我的WPF代码中的另一个参数传递给VB.net代码,该参数是:Binding merged
所以我的Function应该看起来像这样:
If value > 0 and merged = 0 Then Return Visibility.visible
Return Visibility.Collapsed