listpicker显示对象名称而不是属性。我已经尝试了已经在stackoverflow中给出的所有解决方案但是我没有得到任何结果
BorderThickness="0.2" SelectionMode="Multiple" SelectionChanged="AreaClassification_SelectionChanged"
VerticalAlignment="Bottom" Margin="204,-53,0,0" BorderBrush="Black" >
<toolkit:ListPicker.ItemTemplate>
<DataTemplate>
<StackPanel >
<TextBlock Text="{Binding name}" Foreground="Black" FontSize="18"/>
</StackPanel>
</DataTemplate>
</toolkit:ListPicker.ItemTemplate>
<toolkit:ListPicker.FullModeItemTemplate>
<DataTemplate>
<StackPanel>
<TextBlock Text="{Binding name}" FontSize="18" Foreground="White" />
</StackPanel>
</DataTemplate>
</toolkit:ListPicker.FullModeItemTemplate>
</toolkit:ListPicker>
我只需要学习如何设计一个控件。你有没有参考?
代码隐藏
string result = e.Result;
JObject o = JObject.Parse(result);
var results = o["Data"]["Area"];
JArray obj = results as JArray;
var dt = obj.ToArray();
foreach (var d in dt)
{
Area dts = new Area();
dts.code = Convert.ToString(d["code"]);
dts.name = Convert.ToString(d["name"]);
_lst.Add(dts);
}
AreaClassification.ItemsSource = _lst;
答案 0 :(得分:1)
经过大量研究后我发现了这个
AreaClassification.SummaryForSelectedItemsDelegate += SummarizeTeams;
protected string SummarizeTeams(IList selection)
{
string str = "*None Selected*";
if (null != selection && selection.Count > 0)
{
StringBuilder contents = new StringBuilder();
int idx = 0;
foreach (object o in selection)
{
if (idx > 0) contents.Append(", ");
contents.Append(((Area)o).name);
idx++;
}
str = contents.ToString();
}
return str;
}
显示项目列表我们需要在c#上使用SummaryForSelectedItemsDelegate方法。我希望它能帮助其他人