从 Infragistics 菜单拖放

Drag & Drop from Infragistics Menu

我想 darg&drop 从 Infragistics 菜单 像一个按钮(实际上它后面的任何 UI 元素)到 Grid.

但是好像做不到

通常我喜欢

 <Border Margin="2,0" CornerRadius="5" Name="MyControl1" BorderBrush="LightGray" BorderThickness="1"  MouseLeftButtonDown="captureMyControl1_MouseLeftButtonDown" MouseLeftButtonUp="captureMyControl1_MouseLeftButtonUp" MouseMove="captureMyControl1_MouseMove">

而且我可以拖放它,因为它有适当的方法。 但似乎我们不能用 Infragistics 功能区菜单

来做到这一点

和此代码

<ig:XamRibbonTabItem>
 <ig:XamRibbonGroup>
  <ig:VerticalRibbonToolContainer>
     <Border Margin="2,0" CornerRadius="5" Name="MyControl1" 
          <tools:ButtonToolEx 

我的意思是我看不到 Ribbon Button 有那些方法,或者我们可以在上面添加 Border

我的问题可能会被重新定义为:我们可以在 Infragistics 菜单中使用标准的 SIlverlight 控件吗? 有什么线索吗?

最后,我找到了解决该问题的方法。

我不会放代码,因为有很多东西,但我会参考这个很棒的 link

http://www.infragistics.com/community/forums/t/39619.aspx

现在想象一下,您可以

而不是 private ComboBox _combo;
 private MyCUstomUSerControl _myCUstomUSerControl;

这是在 Infragistics 功能区菜单.

中实现任何自定义用户控件的方法

伙计们,祝你有愉快的一天!

public class ComboBoxTool : RibbonTool

    {

        protected override RibbonToolBaseControl ResolveToolControl()

        {

            return new ComboBoxToolControl(this);

        }

        public IEnumerable ItemsSource { get; set; }    

    }

    public class ComboBoxToolControl : RibbonToolBaseControl, IRibbonControl

    {

        private ComboBox _combo;

        public ComboBoxToolControl()

        {           

            this.DefaultStyleKey = typeof(ComboBoxToolControl);            

        }

        public ComboBoxToolControl(RibbonToolBase tool) : base(tool)

        {

            this.DefaultStyleKey = typeof (ComboBoxToolControl);

        }

        public override void OnApplyTemplate()

        {

            base.OnApplyTemplate();

            this._combo = GetTemplateChild("Combo") as ComboBox;

            if (this._combo != null)

                this._combo.ItemsSource = ((ComboBoxTool) this.Tool).ItemsSource;

        }

    }

Then you need to define the style for the ComboBoxToolControl in your generic.xaml file:



<Style TargetType="cust:ComboBoxToolControl">

        <Setter Property="Foreground" Value="Green"/>

        <Setter Property="Template">

            <Setter.Value>

                <ControlTemplate TargetType="cust:ComboBoxToolControl">

                    <Grid x:Name="LayoutRoot" HorizontalAlignment="Stretch" Background="Transparent">

                        <Grid >

                            <ComboBox x:Name="Combo" Width="100" Height="24" />

                        </Grid>

                    </Grid>

                </ControlTemplate>

            </Setter.Value>

        </Setter>

    </Style>





At this point you should be able to add your combo box tool to the ribbon:



<igr:XamWebRibbonTabItem>

                    <igr:XamWebRibbonGroup>

                        <cust:ComboBoxTool ItemsSource="{StaticResource inventory}">                       

                      </cust:ComboBoxTool>

                    </igr:XamWebRibbonGroup>                  

 </igr:XamWebRibbonTabItem>

P.S。看看这个 link 以及 http://www.infragistics.com/samples/wpf/ribbon/custom-tools