主要用于記錄工作中發現的一些問題和常見的解決方法。
此文會持續更新。
>abp new Evan.MyWpfApp -t wpf --old --framework .net8
1. 解決不同屏幕分辨率下的鋸齒問題
UseLayoutRounding="True"
<Grid UseLayoutRounding="True"><Border Margin="10" Width="175" Height="Auto" BorderThickness="10" BorderBrush="Black" CornerRadius="5"><Grid><Grid.RowDefinitions><RowDefinition></RowDefinition></Grid.RowDefinitions><Button Content="156"></Button></Grid></Border></Grid>
2. 解決小尺寸文本模糊的問題FontSize小于
<StackPanel><TextBlock FontSize="12" Margin="5">This is a Test. Ideal text is blurry at small size.</TextBlock><!--利用GDI渲染小文本--><TextBlock FontSize="12" Margin="5" TextOptions.TextFormattingMode="Display">This is a Test. Ideal text is blurry at small size.</TextBlock></StackPanel>
3. 增加快捷鍵
<StackPanel><!--按下Alt+A,txtA會自動獲取焦點. lblA的內容: A下面會顯示下劃線--><Label x:Name="lblA" Content="Choose _A" Target="{Binding ElementName=txtA}"></Label><TextBox x:Name="txtA" Width="150"></TextBox><!--按下Alt+B,txtB會自動獲取焦點。lblB的內容: B下面不會顯示下劃線,下劃線顯示在B前面--><Label x:Name="lblB" Content="Choose __B" Target="{Binding ElementName=txtB}"></Label><TextBox x:Name="txtB" Width="150"></TextBox></StackPanel>