2013-02-27 2 views
0

나는 잠시 동안 telerik의 사이트를 검색했으며 stacklayoupanel의 요소에 맞게 크기를 조정하는 방법에 대한 언급을 찾을 수 없습니다. 요소에 맞게 크기를 조정할 수있는 속성이 있습니다. 그러나 이러한 속성은 나를 위해 작동하지 않습니다. 나는 여기에 누가 이것을 사용했고 나를 도울 수있는 사람이 있는지 궁금해하고 있었다. 나는 그 내용에 맞지 않는 listViewVisualItems를 가진리스트 뷰를 가지고있다. 오히려 내용이 아래의 시각적 항목에서 누출되어 다음 항목으로 유출됩니다. 여기 내 맞춤 항목 클래스가 있습니다.내용에 맞게 스택 레이아웃 패널의 크기를 조정하는 방법은 무엇입니까?

public class ChargePlotListViewItem : SimpleListViewVisualItem 
{ 
    private LightVisualElement imageElement; 
    private LightVisualElement titleElement; 
    private LightVisualElement bioElement; 
    private StackLayoutPanel stackLayout; 

    protected override void CreateChildElements() 
    { 
     base.CreateChildElements(); 

     stackLayout = new StackLayoutPanel(); 
     stackLayout.Orientation = System.Windows.Forms.Orientation.Vertical; 
     //stackLayout.AutoSize = true; These do not work 
     //stackLayout.AutoSizeMode = RadAutoSizeMode.WrapAroundChildren; 

     imageElement = new LightVisualElement(); 
     imageElement.DrawText = false; 
     imageElement.ImageLayout = System.Windows.Forms.ImageLayout.Zoom; 
     //imageElement.StretchVertically = false; 
     imageElement.Margin = new System.Windows.Forms.Padding(1, 1, 1, 2); 
     imageElement.ShouldHandleMouseInput = false; 
     imageElement.NotifyParentOnMouseInput = true; 
     imageElement.AutoSizeMode = RadAutoSizeMode.FitToAvailableSize; 

     //stackLayout.Children.Add(imageElement); 

     titleElement = new LightVisualElement(); 
     titleElement.TextAlignment = ContentAlignment.TopCenter; 
     titleElement.Margin = new Padding(2, 1, 1, 2); 
     titleElement.Font = new System.Drawing.Font("Segoe UI", 8, FontStyle.Italic, GraphicsUnit.Point); 
     titleElement.ShouldHandleMouseInput = false; 
     titleElement.NotifyParentOnMouseInput = true; 
     stackLayout.Children.Add(titleElement); 

     bioElement = new LightVisualElement(); 
     bioElement.TextAlignment = ContentAlignment.BottomLeft; 
     bioElement.ShouldHandleMouseInput = false; 
     bioElement.NotifyParentOnMouseInput = true; 
     bioElement.Margin = new Padding(2, 1, 1, 2); 

     bioElement.Font = new System.Drawing.Font("Segoe UI", 9, FontStyle.Regular, GraphicsUnit.Point); 
     bioElement.ForeColor = Color.FromArgb(255, 114, 118, 125); 
     stackLayout.Children.Add(bioElement); 

     this.Children.Add(stackLayout); 
     //this.stackLayout.Measure(new System.Drawing.SizeF((float)stackLayout.Size.Width, (float)20)); 

     this.Padding = new Padding(1, 2, 1, 2); 
     this.Shape = new RoundRectShape(3); 
     this.BorderColor = Color.Black; 
     this.BorderGradientStyle = GradientStyles.Solid; 
     this.DrawBorder = true; 
     this.DrawFill = true; 
     this.BackColor = Color.Azure; 
     this.GradientStyle = GradientStyles.Solid; 
    } 


    protected override void SynchronizeProperties() 
    { 
     base.SynchronizeProperties(); 

     frmBingMaps.CriminalPlotObject plotObject = this.Data.Value as frmBingMaps.CriminalPlotObject; 
     if (plotObject != null) 
     { 
      try 
      { 
       this.imageElement.Image = Crime_Information_System.Properties.Resources 
        .bullet_blue; 
      } 
      catch 
      { 
      } 

      //building the title for the element depending on which names are on record 
      StringBuilder NameBuilder = new StringBuilder(); 
      if (plotObject.Data.FirstName != null | plotObject.Data.FirstName != string.Empty) 
       NameBuilder.Append(plotObject.Data.FirstName + " "); 

      if (plotObject.Data.LastName != null | plotObject.Data.LastName != string.Empty) 
       NameBuilder.Append(plotObject.Data.LastName + " "); 
      //NameBuilder.Append(" Charge: " + gangBanger.Incidents[0].Charges[0].ChargeDescription); 

      this.titleElement.Text = NameBuilder.ToString(); 

      StringBuilder BioBuilder = new StringBuilder(); 
      //this.radDesktopAlert1.ContentText = "<html><b>" + CentralDataStore.AllUsers.Find(P => P.intUserID 
      // == BLAH.SenderID).strFirstName + " " + CentralDataStore.AllUsers.Find(P => P.intUserID == 
      //  BLAH.SenderID).strLastName + "</b><br>" + BLAH.Subject; 
      BioBuilder.Append("<html>"); 
      BioBuilder.Append("<b>Incident ID</b>: " + plotObject.Data.Incidents.Find(
       P => P.IncidentID == plotObject.CaseID).IncidentID.ToString()); 
      BioBuilder.Append("<br>"); 
      BioBuilder.Append("<b>Date</b>: " + plotObject.Data.Incidents.Find(
       P => P.IncidentID == plotObject.CaseID).DateOfIncident.ToShortDateString()); 
      BioBuilder.Append("<br>"); 
      BioBuilder.Append(plotObject.Data.Incidents.Find(P => P.IncidentID == plotObject 
       .CaseID).Description); 
      BioBuilder.Append("<br>"); 
      //BioBuilder.Append("\r\n"); 
      BioBuilder.Append("<b>Location</b>: "); 
      BioBuilder.Append(plotObject.Data.Incidents.Find(P => P.IncidentID == 
       plotObject.CaseID).Location); 

      BioBuilder.Append("<br>"); 
      //BioBuilder.Append("\r\n"); 
      BioBuilder.Append(string.Format("<b>Charges</b>: ")); 

      foreach (Charge c in plotObject.Data.Incidents.Find(P => P.IncidentID == plotObject.CaseID 
       ).Charges) 
      { 
       BioBuilder.Append(c.ChargeDescription + ", "); 
      } 

      BioBuilder.Remove(BioBuilder.Length - 2,2); 
      //BioBuilder.Append(" 
      bioElement.Text = BioBuilder.ToString(); 

      this.Text = ""; //here to erase the system.crimesysteminformation.plot blah object name 

     } 
    } 

    protected override Type ThemeEffectiveType 
    { 
     get 
     { 
      return typeof(IconListViewVisualItem); 
     } 
    } 

    protected override SizeF MeasureOverride(SizeF availableSize) 
    { 
     SizeF measuredSize = base.MeasureOverride(availableSize); 
     this.stackLayout.Measure(measuredSize); 
     return measuredSize; 
    } 

    protected override SizeF ArrangeOverride(SizeF finalSize) 
    { 
     base.ArrangeOverride(finalSize); 
     this.stackLayout.Arrange(new RectangleF(PointF.Empty, finalSize)); 
     return finalSize; 
    } 

답변

0

이 문제를 극복하기 위해, 항목이 다음과 같은 속성을 설정하여 원하는 크기를 취할 수 있도록 고려하시기 바랍니다 : 귀하의 편의를 위해

radListView1.AllowArbitraryItemHeight = true; 

을 여기에 행동 코드의 단순화 된 버전은 다음과 같습니다

void radListView1_VisualItemCreating(object sender, ListViewVisualItemCreatingEventArgs  e) 
{ 
e.VisualItem = new ChargePlotListViewItem(); 
} 

public class ChargePlotListViewItem : SimpleListViewVisualItem 
{ 
private LightVisualElement imageElement; 
private LightVisualElement titleElement; 
private LightVisualElement bioElement; 
private StackLayoutPanel stackLayout; 

protected override void CreateChildElements() 
{ 
    base.CreateChildElements(); 

    stackLayout = new StackLayoutPanel(); 
    stackLayout.Orientation = System.Windows.Forms.Orientation.Vertical; 

    imageElement = new LightVisualElement(); 
    imageElement.DrawText = false; 
    imageElement.ImageLayout = System.Windows.Forms.ImageLayout.Center; 
    imageElement.ShouldHandleMouseInput = false; 
    imageElement.NotifyParentOnMouseInput = true; 

    stackLayout.Children.Add(imageElement); 

    titleElement = new LightVisualElement(); 
    titleElement.TextAlignment = ContentAlignment.TopCenter; 
    titleElement.Font = new System.Drawing.Font("Segoe UI", 8, FontStyle.Italic, GraphicsUnit.Point); 
    titleElement.ShouldHandleMouseInput = false; 
    titleElement.NotifyParentOnMouseInput = true; 
    stackLayout.Children.Add(titleElement); 

    bioElement = new LightVisualElement(); 
    bioElement.TextAlignment = ContentAlignment.BottomLeft; 
    bioElement.ShouldHandleMouseInput = false; 
    bioElement.NotifyParentOnMouseInput = true; 
    bioElement.Margin = new Padding(2, 1, 1, 2); 
    bioElement.Font = new System.Drawing.Font("Segoe UI", 9, FontStyle.Regular, GraphicsUnit.Point); 
    bioElement.ForeColor = Color.FromArgb(255, 114, 118, 125); 

    stackLayout.Children.Add(bioElement); 

    this.Children.Add(stackLayout); 
} 

protected override void SynchronizeProperties() 
{ 
    base.SynchronizeProperties(); 
    DataRowView rowView = this.Data.DataBoundItem as DataRowView; 

    imageElement.Image = (Image)rowView.Row["Image"]; 
    titleElement.Text = rowView.Row["Title"].ToString(); 
    bioElement.Text = rowView.Row["Bio"].ToString(); 
    this.Text = ""; //here to erase the system.crimesysteminformation.plot blah object name 
} 

protected override Type ThemeEffectiveType 
{ 
    get 
    { 
     return typeof(IconListViewVisualItem); 
    } 
} 
} 
+0

완벽하게 작동했습니다. 고마워요. – Adrian

+0

당신은 환영합니다. – checho

관련 문제