我遇到了 RibbonToolTips 从功能区中的文本框继承对齐方式的问题。问题是,无论我做什么,我似乎都无法覆盖这种行为。这似乎只体现在文本框和标签上,而 RibbonTextBoxes 似乎不受影响。
XAML:
<RibbonWindow x:Class="RibbonToolTipTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid x:Name="LayoutRoot">
<Ribbon Title="WPF Ribbon" x:Name="Ribbon">
<RibbonTab>
<RibbonGroup Width="300">
<StackPanel Orientation="Horizontal">
<TextBox Text="This is a test" TextAlignment="Right" x:Name="RegularLabel" />
<TextBox Width="200" TextAlignment="Left" x:Name="RegularTextBox"/>
</StackPanel>
<RibbonTextBox Width="200"
ToolTipTitle="Title"
ToolTipDescription="The moon was shining sulkily, Because she thought the sun Had got no business to be there After the day was done — "It's very rude of him," she said, "To come and spoil the fun.""
Label="Label" />
</RibbonGroup>
</RibbonTab>
</Ribbon>
</Grid>
代码隐藏:
using System.Windows.Controls.Ribbon;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace RibbonToolTipTest
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : RibbonWindow
{
public MainWindow()
{
InitializeComponent();
RegularTextBox.ToolTip = RegularLabel.ToolTip = new RibbonToolTip()
{
Title = "Title",
Description =
"The sun was shining on the sea, Shining with all his might: He did his very best to make The billows smooth and bright — And this was odd, because it was The middle of the night. ",
HorizontalContentAlignment = HorizontalAlignment.Left,
HorizontalAlignment = HorizontalAlignment.Left
};
}
}
}