English 中文(简体)
创建不同血缘细胞的滚动网
原标题:Creating a scrolling grid of different width cells

我是新鲜的,可以打上“光”和“温Phone7”的发展,如果有人可能如此,则需要某种指导,以便免除我的无知。

我需要为《电视指南》树立一个格丽德观点,在电视指南中,你有一个垂直的频道标志清单,显示这种滚动和倒塌的左侧,以及我们拥有一个横向和纵向滚动网的权利。 横向滚动机将固定在屏幕上的航道标志移出,但垂直滚动电网也像你所期望的那样将标志推移。

我是否应该继续利用XAML和银灯这样做,或者我是否应该通过XNA这样做?

我问,因为我通过银星尝试了几种不同的方法,以接手我遇到的两个主要问题:

Performance

由于我收到我们的Adync要求提供的数据,我创建了一个背景工人读物,把JSON混为一谈,并在电网信道上使用分机设立方案小组。 Invoke。 由于这种情况没有逐步反馈,整个事情都等待着所有工作,然后突然出现电网。 我希望这些囚室通过渠道或以电池板为基础,在不阻挡技经评估组的这种滚动作用的情况下,只好事,但似乎确实如此。

我有问题,因为使用UIElements的任何工作都是在WinPhone7 是主线(我相信)的“ID”深线上进行的,这包括教 XXAML,或创建/改造UIElements,即使他们愿意在屏幕上或看得见的任何东西中添加。 这意味着,我无法通过预先确定或重新使用要素来改进情况。

我尽量在工人的read子里做事,而仅仅在把小块企业的工作派到统一工地以尽量减少封锁方面,这似乎起到了帮助作用。

<>Memory

显然,我无法为每个特赫特方案活动设立方案小组,为期7天(我们支持650多个渠道),因为电话很快就会流出记忆;因此,我要建立一个虚拟网,在网格中设立小组并装入信库,只供眼看。

我有两个问题:

  1. the UI blocking of doing any UI work stops any scrolling as above so creating new cells in the background that are to be scrolled into view cant happen without blocking the UI
  2. there are no scroll events being sent by the scroll view, I have experimented with binding to the scrollbars in the scrollview to get offset values but this doesnt work very well as it just updates in fits and starts so if you do lots of scrolling, nothing gets sent until there is a pause or OnIdle I guess.

难道我会说话,因此,我应该坚持下去,或者我正在做一些必须做的事情,我应该尝试像通过XNA那样做的另一种策略?

任何建议都将受到高度赞赏。

www.un.org/Depts/DGACM/index_spanish.htm Edit: Abit more information and some samples code

I have a Programme class that contains things like start time and title, a Channel class that has name and logo etc but also an array of programmes.

当我检索我的APIC数据时,我制造了一个渠道标,并在各种渠道添加,然后在渠道方案阵列中增加方案。 一频道的所有节目一经插入一阵,就张贴到一个频道节目播放器上,以便更新情报和安全局。

<ScrollViewer ScrollViewer.VerticalScrollBarVisibility="Visible" ScrollViewer.HorizontalScrollBarVisibility="Visible">
    <Canvas x:Name="ProgGrid" 
                    Height="55" Width="393" 
                    VerticalAlignment="Top" HorizontalAlignment="Left">
    </Canvas>
</ScrollViewer>


public void ChannelProgrammesComplete( object sender, EventArgs e )
{
  var bw = new BackgroundWorker();
  bw.WorkerReportsProgress = true;
  bw.DoWork += ( doWorkSender, args ) =>
  {
    Dispatch( (Channel)sender );
  };
  bw.RunWorkerAsync();
}

private void Dispatch( BackgroundWorker bw, object param )
{
  Channel channel = (Channel)param;

  int progCount = 0;
  foreach( Programme programme in channel.Programmes )
  {
    double left = ( ( programme.StartSecsFromToday / 60 ) * PixelsPerMinute );  // turn it into seconds

    if( progCount == 0 && left < 0 )
    {
      // If first prog starts before 6am, shrink the cell so it starts at the 6am start point
      programme.UIWidth = ( ( programme.Duration - ( ( programme.StartSecsFromToday / 60 ) * -1 ) ) * PixelsPerMinute ) - _cellPadding;
      left = 0;
    }
    else
    {
      programme.UIWidth = ( programme.Duration * PixelsPerMinute ) - _cellPadding;  // Multiply by zoom level which is 3 for now, and take off the amount we use for right margin grid separator
    }
    Debug.Assert( programme.UIWidth > 0 );

    programme.UITop = channel.SortIndex * ( _rowHeight + _cellPadding );
    programme.UILeft = left;
    programme.UIHeight = _rowHeight;

    object[] invokeArgs = new object[ 1 ];
    invokeArgs[ 0 ] = programme;

    // Do as much work as possible in the thread before dispatching to the UI thread for the simple UI work
    Dispatcher.BeginInvoke( new InvokeProgrammeCellDelegate( AddProgrammeCellDelegate ), invokeArgs );
  }
}


public delegate void InvokeProgrammeCellDelegate( Programme prog );
public void AddProgrammeCellDelegate( Programme prog )
{
  Rectangle progCell = new Rectangle();
  progCell.Fill = new SolidColorBrush( Color.FromArgb( 0xFF, (byte)( 0x13 ), (byte)( 0x45 ), (byte)( 0x70 ) ) );
  progCell.Height = prog.UIHeight;
  progCell.Width = prog.UIWidth;

  progCell.SetValue( Canvas.TopProperty, prog.UITop );
  progCell.SetValue( Canvas.LeftProperty, prog.UILeft );

  ProgGrid.Children.Add( progCell );
  ProgGrid.Width = Math.Max( ProgGrid.Width, prog.UIWidth + prog.UILeft );
}
最佳回答

首先,使用一个大型的<代码>Canvas只应是最后的手段,在大多数情况下,<代码>Grid或StackPanel(有时其他<代码>:Stacknels)和带有<代码>Margin的物项的合并速度要快得多(但操作难度会小一些)。

保持你能够做出的反应

  1. Only load small chunks of data at once (like, for example, two pages. This will greatly decrease the amount of data being rendered simultaneously). Then you can load the next chunk either immediately or when the user scrolls at the end of the list.
  2. Speed down the result processing. If you wait 100ms after inserting each item (or 1 second after each channel, if you want to have the channel loaded at once), the impact on responsiveness should be almost gone while having no too large impact on loading time. The times mentioned are only estimates, if they are too large/small feel free to adjust them according too your needs to provide a smooth user experience.
问题回答

暂无回答




相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签