C# 将列表框项绑定到wp8中最高文本(如数字)的中间位置
我需要显示包含文本块(文本为90,20,30,50,70)的动态数据。在这种情况下,我需要显示如下内容:最大值应位于列表框的中间,次高值应位于右侧,第三高值应位于左侧,水平方向 视图: 2050907030C# 将列表框项绑定到wp8中最高文本(如数字)的中间位置,c#,wpf,windows-phone-8,listbox,C#,Wpf,Windows Phone 8,Listbox,我需要显示包含文本块(文本为90,20,30,50,70)的动态数据。在这种情况下,我需要显示如下内容:最大值应位于列表框的中间,次高值应位于右侧,第三高值应位于左侧,水平方向 视图: 2050907030 <ListBox Name="wifiListboxItems" Height="350" Width="467" Canvas.Left="4" HorizontalContentAlignment="Center" SelectionChanged="wifiListboxIt
<ListBox Name="wifiListboxItems" Height="350" Width="467" Canvas.Left="4" HorizontalContentAlignment="Center" SelectionChanged="wifiListboxItems_SelectionChanged_1" ItemsSource="{Binding ItemCollection}" ScrollViewer.HorizontalScrollBarVisibility="Auto" ScrollViewer.VerticalScrollBarVisibility="Disabled">
<ListBox.ItemsPanel>
<ItemsPanelTemplate >
<wptoolkit:WrapPanel Margin="150,0,150,0" HorizontalAlignment="Center">
</wptoolkit:WrapPanel>
</ItemsPanelTemplate>
</ListBox.ItemsPanel>
<ListBox.ItemTemplate>
<DataTemplate>
<StackPanel Name="stackpanle" Loaded="stackpanle_Loaded" Orientation="Horizontal" Height="auto" Width="auto">
<Grid Name="gridim">
<Border Height="{Binding Name,Converter={StaticResource HeightConverterTest}}" Width="130" Margin="5" VerticalAlignment="Top" Background="#96345a" CornerRadius="0,0,80,80"/>
<Image Name="imgicon" Height="50" Width="50" Stretch="Fill" HorizontalAlignment="Center" Margin="0,40,0,50" VerticalAlignment="Bottom" Source="{Binding AppIcon}"/>
<TextBlock Name="tblPer" Text="{Binding Name}" HorizontalAlignment="Center" Margin="0,10,0,0" VerticalAlignment="Top" ></TextBlock>
</Grid>
</StackPanel>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
public class HomePageHeightConverterr:IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string temp = value.ToString();
temp = temp.Remove(temp.Length - 1, 1);
double standardHeight = 120;
double height;
double.TryParse(temp, out height);
double returnHeight = standardHeight + (height * 2);
return returnHeight;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
公共类HomePageHeightConverter错误:IValueConverter
{
公共对象转换(对象值、类型targetType、对象参数、System.Globalization.CultureInfo区域性)
{
字符串温度=value.ToString();
温度=移除温度(温度长度-1,1);
双标准高度=120;
双高;
双锥虫(温度、外高度);
双返回高度=标准高度+(高度*2);
返回高度;
}
公共对象转换回(对象值、类型targetType、对象参数、System.Globalization.CultureInfo区域性)
{
抛出新的NotImplementedException();
}
}
在这里我将得到返回高度,比如90,40,60,70,80。现在我必须绑定在列表框中,列表框在中间最高,第二高在右侧,第三高在左侧
如果您有任何帮助,我们将不胜感激。这里的列表框在哪里使用。。?发布一些你迄今为止尝试过的代码。。您的问题似乎很简单,但您需要详细说明。在viewmodel中根据需要对数据进行排序,然后绑定到listbox。如果您确实希望社区提供帮助,请共享一些代码以显示您的努力you@KevalLangalia尼特,请检查一下,我编辑了一些代码。