问题:按下并释放Alt键后,如何退出键盘热键模式?在Office中的ESC作品,在WPF中它没有.
详细信息:我Label在WPF应用程序中有各种元素.
<StackPanel>
<Label Grid.Column="0" VerticalAlignment="Center" Content="_Textbox 1" Target="textbox1" />
<TextBox x:Name="textbox1" Width="50" />
<Label Grid.Column="0" VerticalAlignment="Center" Content="T_extbox 2" Target="textbox2" />
<TextBox x:Name="textbox2" Width="50" />
</StackPanel>
Run Code Online (Sandbox Code Playgroud)
当我按下并释放Alt键时,P保持下划线,然后我可以单独按下P键,Label就会采取行动.这与Word 2013和Notepad的工作方式相同,因为您无需同时按Alt和P.
WPF不同的地方是我不能ESC按键来停止下划线并停止自动导航到Label控件.我看到退出键盘导航模式的唯一方法是使用鼠标并单击某处,从而击败键盘导航的目标.
我想编写一个类似于的控件ComboBox,我想知道是否有人知道如何检测用户何时单击ComboBox边界之外。ComboBox在这种情况下关闭它的下拉菜单。
我正在使用autofac解析WPF应用程序中的Views和ViewModels。IComponentContext被自动传递到视图中。
一个例子:
public BusinessAuto(int proposedCoverageId, IComponentContext componentContext)
{
DataContext = componentContext.Resolve<BusinessAutoViewModel>(new TypedParameter(typeof(Int32), proposedCoverageId));
InitializeComponent();
}
Run Code Online (Sandbox Code Playgroud)
在此视图的XAML中,正在创建具有自己的ViewModel的UserControl。一个例子:
<userControl:AdditionalCoveragesControl Margin="0,10"/>
Run Code Online (Sandbox Code Playgroud)
Autofac不会创建UserControl(视图是),因此Autofac无法将依赖项注入UserControl的构造函数中。
如何将对IComponentContext的引用获取到初始视图的XAML中声明的UserControl中?
我觉得我要么需要Autofac以某种方式创建我的UserControl,要么需要恢复到不鼓励使用的Global静态容器(ick),或者我必须使用DependencyProperty将容器向下传递(也请单击ick)。
我有一个Border用Content的TextBlock,我想完美水平和垂直居中。无论我尝试什么,它都不会看起来居中。我错过了什么?
使用代码下方文字顶部边框下方19px,文字底部边框上方5px。它也偏离中心左侧或右侧,具体取决于Text我认为与字体相关的值。
该解决方案应该适用于任何字体的不同文本 (1-31)。
代码
<Grid Width="50" Height="50">
<Border BorderThickness="1" BorderBrush="Black">
<TextBlock Text="13" VerticalAlignment="Center" HorizontalAlignment="Center" FontSize="50"/>
</Border>
</Grid>
Run Code Online (Sandbox Code Playgroud)
结果

