I have the following XAML code, where I Bind some data to the listview. Also, I have very important RecipientConverter
which allows me to convert my TextBlock. But, here is the problem. This TextBlock must be converter according to the form presented in the TextBlock below (Binding Path=Sum).
So, here is my question, is it possible to send the "Sum" TextBlock as ConverterParameter to the RecipientConverter
? I know about MultipleBinding
, but this is only suitable for WPF and it is not available in UWP. Maybe here is a way of implementing it with DependencyProperty
, but I'm note sure about that.
NOTE: "Recipient" TextBlock and "Sum" TextBlock are dynamic values which I get from the server.
<ListView x:Name="HistoryList" Padding="10" IsItemClickEnabled="True" Visibility="Collapsed" ItemsSource="{Binding Source={StaticResource TransactionsCVS}}" ItemsPanel="{StaticResource ResourceKey=ItemsPanelTemplate}" ItemClick="HistoryList_ItemClick">
<ListView.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate x:DataType="data:TransactionGroupInfo">
<TextBlock FontWeight="Medium" FontSize="16" Foreground="#999999" Text="{Binding Path=Key}" />
</DataTemplate>
</GroupStyle.HeaderTemplate>
</GroupStyle>
</ListView.GroupStyle>
<ListView.ItemTemplate>
<DataTemplate x:DataType="data:Transaction">
<Grid Height="60" Margin="0,5,0,5" Background="White" CornerRadius="5">
<Grid.ColumnDefinitions>
<ColumnDefinition Width="5" />
<ColumnDefinition Width="*" />
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<StackPanel Background="{Binding Path=VendorAccentColor}" CornerRadius="5,0,0,5" />
<StackPanel VerticalAlignment="Center" Margin="10,0,0,0" Grid.Column="1" Orientation="Vertical">
<TextBlock Text="{Binding Path=VendorName}" FontSize="16" Foreground="#999999" />
<TextBlock Text="{Binding Path=Recipient, Converter={StaticResource RecipientConverter}}" FontSize="16" Foreground="#999999" />
</StackPanel>
<TextBlock Grid.Column="2" Text="{Binding Path=Sum, Converter={StaticResource SumConverter}}" VerticalAlignment="Center" Canvas.ZIndex="2" Margin="0,0,10,0" FontSize="18" FontWeight="Bold" />
</Grid>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
And here is C# code of my Converter
public object Convert(object value, Type targetType, object parameter, string language)
{
string recipient = (string)value;
// Here is a way I want it to be
string sum = (string)parameter;
if (HalykWallet_v03.Model.AppSettings.GetAppLang() == "ru")
{
if (sum.Contains("-"))
return "На " + recipient;
else
return "От " + recipient;
}
else
{
char[] array = sum.ToCharArray();
if (sum.Contains("-"))
{
switch (array.Last())
{
case '0':
case '1':
case '2':
recipient += recipient + "-ден";
break;
case '3':
case '4':
case '5':
recipient += recipient + "-тен";
break;
case '6':
recipient += recipient + "-дан";
break;
case '7':
case '8':
recipient += recipient + "-ден";
break;
case '9':
recipient += recipient + "-дан";
break;
default:
break;
}
}
else
{
switch (array.Last())
{
case '0':
case '1':
case '2':
recipient += recipient + "-ге";
break;
case '3':
case '4':
case '5':
recipient += recipient + "-ке";
break;
case '6':
recipient += recipient + "-ға";
break;
case '7':
case '8':
recipient += recipient + "-ден";
break;
case '9':
recipient += recipient + "-ға";
break;
}
}
return recipient;
}
}