여기 내 추가 참조
public class items
{
public string item_name { get; set; }
public string item_id { get; set; }
public string item_quantity { get; set; }
public string unit_id { get; set; }
}
public class services
{
public List<items> items { get; set; }
}
모달
내 List.I 단위 이름을 표시 할 필요에 대해 내가 itemsource으로 위 클래스의 객체를 할당하고, 하지만 내 개체는 단위 ID 만 가지고 있기 때문에 사전에서 가져 와서 변환기를 사용하여 바인딩합니다.
XAML에서이 변환기를 참조 할 수 없습니다.이 변환기는 네임 스페이스와 다른 클래스 내에 직접 포함되어 있지 않으므로이 변환기를 참조 할 수 없습니다.
Namespace myname
{
public partial class write : PhoneApplicationPage
{
public static Dictionary<String, String> units1 = new Dictionary<String, String>();
public write()
public class UnitConvertor : IValueConverter
{
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
string text = value.ToString();
if (text != null)
{
String unit = units1[text];
return unit;
}
return value;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return value;
}
}
}
}
XAML 페이지 :
xmlns:local="clr-namespace:myname"
내가 <Grid.resources>
컨버터를 사이드 클래스에 배치하고 참조하십시오. 왜 그것을 생성자 안에 썼습니까? – asitis
나는 사전을 사용하고 있기 때문에 네임 스페이스 아래에 직접 사전을 선언 할 수 없기 때문에 ... –