最后,我找到了解决这个问题的方法。
我不会写代码,因为有很多东西,但我会参考这个伟大的链接
http://www.infragistics.com/community/forums/t/39619.aspx
现在想象一下
private ComboBox _combo;
你可以这样做
private MyCUstomUSerControl _myCUstomUSerControl;
这是一种在
Infregistics功能区菜单
.
祝你今天愉快,伙计们!
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.还有一个链接
http://www.infragistics.com/samples/wpf/ribbon/custom-tools