실버라이트4 Beta 에서 문자열 인덱서를 대상으로 바인딩이 가능 하게 되었는데요. 여기다가 프로퍼티 인덱서를 이용하면 이렇게도 바인딩이 가능하네요
우선 SL4에서 제공 되는 문자열 인덱서를 알아보면요
여기서 쵸큼만 더 나아가서 Employee에다가 다음과 같이 인덱서를 추가 하고요
public string this[string key]
{
get
{
if (_customProperties == null)
{
_customProperties = new Dictionary<string, object>();
return string.Empty;
}
if (_customProperties.ContainsKey(key) == true)
return _customProperties[key].ToString();
else
return string.Empty;
}
set
{
if (_customProperties == null)
{
_customProperties = new Dictionary<string, object>();
}
_customProperties.Add(key, value);
}
}
그후에는 다음과 같이 바인딩이 가능하네요.
<TextBlock Text="{Binding [Nickname]}"/>
머 그렇다고요 -.,-;;