2011-03-01 48 views

回答

2

第一步是定义您自己的ComboBox模板,其中包含Popup的定义。例如,使用Blend编辑副本。

但是,将上面的Popup放在上面并不是一件容易的事,因为Silverlight Popups没有像WPF中那样的PlacementPlacementTarget属性,它可以在上面显示它。

幸运的是Kent Boogaart wrote an Attached Behavior,增加了这种能力,它是这样使用:

<Popup b:PopupPlacement.PlacementTarget="{Binding ElementName=ContentPresenterBorder}"> 
    <b:Popup.PreferredOrientations> 
     <b:PopupOrientationCollection> 
      <b:PopupOrientation Placement="Top" HorizontalAlignment="Center"/> 
      <b:PopupOrientation Placement="Bottom" HorizontalAlignment="Center"/> 
      <b:PopupOrientation Placement="Right" VerticalAlignment="Center"/> 
      <b:PopupOrientation Placement="Right" VerticalAlignment="TopCenter"/> 
     </b:PopupOrientationCollection> 
    </b:Popup.PreferredOrientations> 

    <!--Popup content with the ItemPresenter--> 
</Popup> 

哪里ContentPresenterBorder是保存ComboBox的切换按钮的容器的名称。

+0

是否可以将代码发布到不同的位置?上述链接中的https://skydrive.live.com地址被我公司的代理服务器阻止......(或者也许只是将源代码粘贴到单独的答案中?这可能会更好,以防文件被删除/移动/ etc) – 2013-04-02 21:44:10

+0

如果你的公司在你使用他们的技术的时候阻止了微软的网站,那你就麻烦了:)有太多的文件要粘贴在这里,对你来说什么是合适的位置?还是通过电子邮件? – Mart 2013-04-03 06:49:01

+0

感谢玛特,我同意阻止网站通常不是很有成效。我最终把自己的文件通过电子邮件发送给家里,所以我都准备好了。 – 2013-04-05 18:00:37