0
사용자 정의 컨트롤이 있습니다. 기본적으로 연결된 문자열을 바인딩 할 수있는 stacklayout이 있으며 태그 목록과 같은 여러 개체로 구분됩니다.xamarin이 사용자 정의 컨트롤을 구성합니다.
public void Render()
{
if (ItemsSource == null)
return;
this.Orientation = Orientation == StackOrientation.Vertical ? StackOrientation.Vertical : StackOrientation.Horizontal;
this.Margin = new Thickness (0, 0, 0, 0);
List<string> items = ItemsSource.Split('|').ToList();
foreach (var item in items)
{
var frame = new Frame();
frame.BindingContext = item;
frame.BackgroundColor = Color.FromHex("#FCFACF");
frame.OutlineColor = Color.FromHex("#D0C0AD");
frame.HasShadow = false;
frame.Padding = new Thickness(4, 2, 4, 0);
var label = new Label();
label.Text = "{Binding}";
label.FontSize = 10;
label.Parent = frame;
Children.Add(frame);
}
}
하지만 난이 권리를 얻을 수없는 것, 어떻게 내가 프레임의 자식이 될 수있는 lable가 추가 않으며, 나는에 레이블을 추가 할 경우 어떻게 나는 나의 현재와 같은 바인딩을 수정할 수 있습니다 stacklayout의 하위 항목 인 레이블의 텍스트는 실제 텍스트가 아닌 {바인딩}입니다.
누군가 나를 도와주세요. XAML에서 datatemplate과 viewcell이있는 ItemTemplate을 추가하면이 모든 작업을 수행 할 수 있지만이 작업을 다른 뷰에서 다시 사용하려면 XAML에서이 작업을 수행하지 않아야합니다.
완벽한 감사를 사용하려면 Content 속성을
이있다! –