我有两个RichEditControls和一个自动生成的功能区。
要同时使用两个控件的功能区,请执行以下操作(受this suggestion指导):
<dxre:RichEditControlProvider x:Name="recp" />
这是我的XAML.CS
public TaskView()
{
InitializeComponent();
richEditControl1.GotFocus += RichEditControl1OnGotFocus;
richEditControl2.GotFocus += RichEditControl2OnGotFocus;
}
private void RichEditControl1OnGotFocus(object sender, RoutedEventArgs routedEventArgs)
{
recp.RichEditControl = richEditControl1;
richEditControl2.BarManager = null;
richEditControl1.BarManager = barManager1;
}
private void RichEditControl2OnGotFocus(object sender, RoutedEventArgs routedEventArgs)
{
recp.RichEditControl = richEditControl2;
richEditControl1.BarManager = null;
richEditControl2.BarManager = barManager1;
}
这也允许我将色带用于第二个RichEditControl。
我现在的问题是,有可选的RibbonPages表编辑和图像编辑,这些仅在选择表或图像时显示。 不幸的是,这些控件未与选定的RichEditControl同步,因此我只能将它们用于第一个控件。
这是图片编辑页面的自动生成的XAML代码:
丝带:
<dxr:RibbonPageCategory x:Name="catPictureTools"
Caption="{Binding ConverterParameter=Caption_PageCategoryFloatingObjectPictureTools, Converter={StaticResource stringIdConverter}, Mode=OneTime, Source={StaticResource stringIdConverter}}"
dxre:AttachedCommand.Command="{Binding ToolsFloatingPictureCommandGroup, Mode=OneTime, Source={StaticResource commands}}">
<dxr:RibbonPage x:Name="pagePictureToolsFormat"
Caption="{Binding ConverterParameter=Caption_PageFloatingObjectPictureToolsFormat, Converter={StaticResource stringIdConverter}, Mode=OneTime, Source={StaticResource stringIdConverter}}">
<dxr:RibbonPageGroup x:Name="grpPictureToolsFormatShapeStyles"
Caption="{Binding ConverterParameter=Caption_GroupFloatingPictureToolsShapeStyles, Converter={StaticResource stringIdConverter}, Mode=OneTime, Source={StaticResource stringIdConverter}}"
ShowCaptionButton="False">
<dxr:RibbonPageGroup.ItemLinks>
<dxr:BarButtonGroupLink BarItemName="biShapeColors" />
<dxr:BarButtonGroupLink BarItemName="biShapeOutlineWeight" />
</dxr:RibbonPageGroup.ItemLinks>
</dxr:RibbonPageGroup>
<dxr:RibbonPageGroup x:Name="grpPictureToolsFormatArrange"
Caption="{Binding ConverterParameter=Caption_GroupFloatingPictureToolsArrange, Converter={StaticResource stringIdConverter}, Mode=OneTime, Source={StaticResource stringIdConverter}}"
ShowCaptionButton="False">
<dxr:RibbonPageGroup.ItemLinks>
<dxb:BarSubItemLink BarItemName="biPictureWrapText" />
<dxb:BarSubItemLink BarItemName="biPicturePosition" />
<dxb:BarSubItemLink BarItemName="biPictureBringForwardPlaceholder" />
<dxb:BarSubItemLink BarItemName="biPictureSendBackwardPlaceholder" />
</dxr:RibbonPageGroup.ItemLinks>
</dxr:RibbonPageGroup>
</dxr:RibbonPage>
</dxr:RibbonPageCategory>
BarItems:
<dxr:BarButtonGroup x:Name="biShapeColors">
<dxr:BarButtonGroup.ItemLinks>
<dxre:BarSplitButtonColorEditItemLink BarItemName="biPictureShapeFillColor" />
<dxre:BarSplitButtonColorEditItemLink BarItemName="biPictureShapeOutlineColor" />
</dxr:BarButtonGroup.ItemLinks>
</dxr:BarButtonGroup>
<dxre:BarSplitButtonColorEditItem x:Name="biPictureShapeFillColor"
Command="{Binding PictureShapeFillColor, Mode=OneTime, Source={StaticResource commands}}">
<dxb:PopupControlContainerInfo>
<dxe:ColorEdit EditValue="{Binding EditValue, ElementName=biPictureShapeFillColor, Mode=TwoWay}"
ShowDefaultColorButton="False"
ShowNoColorButton="True"
ShowBorder="False" />
</dxb:PopupControlContainerInfo>
</dxre:BarSplitButtonColorEditItem>
<dxre:BarSplitButtonColorEditItem x:Name="biPictureShapeOutlineColor"
Command="{Binding PictureShapeOutlineColor, Mode=OneTime, Source={StaticResource commands}}">
<dxb:PopupControlContainerInfo>
<dxe:ColorEdit EditValue="{Binding EditValue, ElementName=biPictureShapeOutlineColor, Mode=TwoWay}"
ShowDefaultColorButton="False"
ShowNoColorButton="True"
ShowBorder="False" />
</dxb:PopupControlContainerInfo>
</dxre:BarSplitButtonColorEditItem>
<dxr:BarButtonGroup x:Name="biShapeOutlineWeight">
<dxr:BarButtonGroup.ItemLinks>
<dxb:BarEditItemLink BarItemName="biPictureShapeOutlineWeight" />
</dxr:BarButtonGroup.ItemLinks>
</dxr:BarButtonGroup>
<dxb:BarEditItem x:Name="biPictureShapeOutlineWeight"
Content=""
Command="{Binding PictureShapeOutlineWeight, Mode=OneTime, Source={StaticResource commands}}"
EditWidth="150">
<dxb:BarEditItem.EditSettings>
<dxre:RichEditBorderLineWidthEditSettings RichEditControl="{Binding ElementName=richEditControl1}" />
</dxb:BarEditItem.EditSettings>
</dxb:BarEditItem>
<dxb:BarSubItem x:Name="biPictureWrapText"
Command="{Binding PictureWrapText, Mode=OneTime, Source={StaticResource commands}}">
<dxb:BarSubItem.ItemLinks>
<dxb:BarCheckItemLink BarItemName="biPictureWrapTextSquare" />
<dxb:BarCheckItemLink BarItemName="biPictureWrapTextTight" />
<dxb:BarCheckItemLink BarItemName="biPictureWrapTextThrough" />
<dxb:BarCheckItemLink BarItemName="biPictureWrapTextTopAndBottom" />
<dxb:BarCheckItemLink BarItemName="biPictureWrapTextBehind" />
<dxb:BarCheckItemLink BarItemName="biPictureWrapTextInFrontOf" />
</dxb:BarSubItem.ItemLinks>
</dxb:BarSubItem>
<dxb:BarCheckItem x:Name="biPictureWrapTextSquare"
Command="{Binding PictureWrapTextSquare, Mode=OneTime, Source={StaticResource commands}}" />
<dxb:BarCheckItem x:Name="biPictureWrapTextTight"
Command="{Binding PictureWrapTextTight, Mode=OneTime, Source={StaticResource commands}}" />
<dxb:BarCheckItem x:Name="biPictureWrapTextThrough"
Command="{Binding PictureWrapTextThrough, Mode=OneTime, Source={StaticResource commands}}" />
<dxb:BarCheckItem x:Name="biPictureWrapTextTopAndBottom"
Command="{Binding PictureWrapTextTopAndBottom, Mode=OneTime, Source={StaticResource commands}}" />
<dxb:BarCheckItem x:Name="biPictureWrapTextBehind"
Command="{Binding PictureWrapTextBehind, Mode=OneTime, Source={StaticResource commands}}" />
<dxb:BarCheckItem x:Name="biPictureWrapTextInFrontOf"
Command="{Binding PictureWrapTextInFrontOf, Mode=OneTime, Source={StaticResource commands}}" />
<dxb:BarSubItem x:Name="biPicturePosition"
Command="{Binding PicturePosition, Mode=OneTime, Source={StaticResource commands}}">
<dxb:BarSubItem.ItemLinks>
<dxb:BarButtonItemLink BarItemName="biPictureTopLeftAlignment" />
<dxb:BarButtonItemLink BarItemName="biPictureTopCenterAlignment" />
<dxb:BarButtonItemLink BarItemName="biPictureTopRightAlignment" />
<dxb:BarButtonItemLink BarItemName="biPictureMiddleLeftAlignment" />
<dxb:BarButtonItemLink BarItemName="biPictureMiddleCenterAlignment" />
<dxb:BarButtonItemLink BarItemName="biPictureMiddleRightAlignment" />
<dxb:BarButtonItemLink BarItemName="biPictureBottomLeftAlignment" />
<dxb:BarButtonItemLink BarItemName="biPictureBottomCenterAlignment" />
<dxb:BarButtonItemLink BarItemName="biPictureBottomRightAlignment" />
</dxb:BarSubItem.ItemLinks>
</dxb:BarSubItem>
<dxb:BarButtonItem x:Name="biPictureTopLeftAlignment"
Command="{Binding PictureTopLeftAlignment, Mode=OneTime, Source={StaticResource commands}}" />
<dxb:BarButtonItem x:Name="biPictureTopCenterAlignment"
Command="{Binding PictureTopCenterAlignment, Mode=OneTime, Source={StaticResource commands}}" />
<dxb:BarButtonItem x:Name="biPictureTopRightAlignment"
Command="{Binding PictureTopRightAlignment, Mode=OneTime, Source={StaticResource commands}}" />
<dxb:BarButtonItem x:Name="biPictureMiddleLeftAlignment"
Command="{Binding PictureMiddleLeftAlignment, Mode=OneTime, Source={StaticResource commands}}" />
<dxb:BarButtonItem x:Name="biPictureMiddleCenterAlignment"
Command="{Binding PictureMiddleCenterAlignment, Mode=OneTime, Source={StaticResource commands}}" />
<dxb:BarButtonItem x:Name="biPictureMiddleRightAlignment"
Command="{Binding PictureMiddleRightAlignment, Mode=OneTime, Source={StaticResource commands}}" />
<dxb:BarButtonItem x:Name="biPictureBottomLeftAlignment"
Command="{Binding PictureBottomLeftAlignment, Mode=OneTime, Source={StaticResource commands}}" />
<dxb:BarButtonItem x:Name="biPictureBottomCenterAlignment"
Command="{Binding PictureBottomCenterAlignment, Mode=OneTime, Source={StaticResource commands}}" />
<dxb:BarButtonItem x:Name="biPictureBottomRightAlignment"
Command="{Binding PictureBottomRightAlignment, Mode=OneTime, Source={StaticResource commands}}" />
<dxb:BarSubItem x:Name="biPictureBringForwardPlaceholder"
Command="{Binding PictureBringForwardPlaceholder, Mode=OneTime, Source={StaticResource commands}}">
<dxb:BarSubItem.ItemLinks>
<dxb:BarButtonItemLink BarItemName="biPictureBringForward" />
<dxb:BarButtonItemLink BarItemName="biPictureBringToFront" />
<dxb:BarButtonItemLink BarItemName="biPictureBringInFrontOfText" />
</dxb:BarSubItem.ItemLinks>
</dxb:BarSubItem>
<dxb:BarButtonItem x:Name="biPictureBringForward"
Command="{Binding PictureBringForward, Mode=OneTime, Source={StaticResource commands}}" />
<dxb:BarButtonItem x:Name="biPictureBringToFront"
Command="{Binding PictureBringToFront, Mode=OneTime, Source={StaticResource commands}}" />
<dxb:BarButtonItem x:Name="biPictureBringInFrontOfText"
Command="{Binding PictureBringInFrontOfText, Mode=OneTime, Source={StaticResource commands}}" />
<dxb:BarSubItem x:Name="biPictureSendBackwardPlaceholder"
Command="{Binding PictureSendBackwardPlaceholder, Mode=OneTime, Source={StaticResource commands}}">
<dxb:BarSubItem.ItemLinks>
<dxb:BarButtonItemLink BarItemName="biPictureSendBackward" />
<dxb:BarButtonItemLink BarItemName="biPictureSendToBack" />
<dxb:BarButtonItemLink BarItemName="biPictureSendBehindText" />
</dxb:BarSubItem.ItemLinks>
</dxb:BarSubItem>
<dxb:BarButtonItem x:Name="biPictureSendBackward"
Command="{Binding PictureSendBackward, Mode=OneTime, Source={StaticResource commands}}" />
<dxb:BarButtonItem x:Name="biPictureSendToBack"
Command="{Binding PictureSendToBack, Mode=OneTime, Source={StaticResource commands}}" />
<dxb:BarButtonItem x:Name="biPictureSendBehindText"
Command="{Binding PictureSendBehindText, Mode=OneTime, Source={StaticResource commands}}" />
答案 0 :(得分:3)
好像我找到了答案。 当我问我的问题时,我还没有完成第5步和第6步。后面的代码中也缺少代码。
如果要使用一个功能区具有多个RichEditControl,请按照以下步骤操作:
Binding ElementName=richEditControl1
替换为Binding Path=RichEditControl, ElementName=richEditControlProvider1
或任何第一个RichEditControl和RichEditControlProvider被称为。BarManager
和Ribbon
属性。代码隐藏:
public MyView()
{
InitializeComponent();
richEditControl1.GotFocus += RichEditControl1OnGotFocus;
richEditControl2.GotFocus += RichEditControl2OnGotFocus;
RichEditControl1OnGotFocus(null, null);
}
private void RichEditControl1OnGotFocus(object sender, RoutedEventArgs routedEventArgs)
{
richEditControlProvider1.RichEditControl = richEditControl1;
richEditControl1.Ribbon = ribbonControl1;
richEditControl2.Ribbon = null;
richEditControl1.BarManager = barManager1;
richEditControl2.BarManager = null;
}
private void RichEditControl2OnGotFocus(object sender, RoutedEventArgs routedEventArgs)
{
richEditControlProvider1.RichEditControl = richEditControl2;
richEditControl1.Ribbon = null;
richEditControl2.Ribbon = ribbonControl1;
richEditControl1.BarManager = null;
richEditControl2.BarManager = barManager1;
}