随笔分类 - WPF
摘要:主要用到:RenderTransformOrigin MatrixTransform MatrixAnimationUsingPath DoesRotateWithTangent 直接上代码 <Grid.Resources> <PathGeometry x:Key="PATH" Figures="M
阅读全文
摘要:窗体代码 思路获取主窗体的位置坐标,根据主窗体的位置坐标和长宽尺寸计算子窗体的实际位置,并赋值给子窗体的Top和Left属性。 public partial class PromptDialogBox : Window { /// <summary> /// 关闭计时器 /// </summary>
阅读全文
摘要:可以设置该Listview的触发器如下: <ListView.ItemContainerStyle> <Style TargetType="ListViewItem"> <Style.Triggers> <Trigger Property="IsKeyboardFocusWithin" Value=
阅读全文
摘要:直接上正确代码: 1 <ListView x:Name="lv_product" HorizontalContentAlignment="Stretch" ItemsSource="{Binding Products}" 2 ScrollViewer.HorizontalScrollBarVisib
阅读全文
摘要:在xaml文件中引入命名空间:System.Windows.Forms xmln:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms" 使用方式: <WindowsFormsHost> <wf:PictureBox
阅读全文
摘要:在.net 5.0的wpf项目中添加了System.Windows.Forms.dll引用之后窗体自带的初始化方法直接报错。 解决办法:在项目文件.csproj里的<PropertyGroup>标签子节点添加 <UseWindowsForms>true</UseWindowsForms>
阅读全文
摘要:一、以App扩展方法检查进程名和进程ID的方式 1 Public static T SetSingleProcess(this T app)Where T:Application 2 { 3 var process=Process.GetProcesses().Where(p=>p.ProcessN
阅读全文
摘要:xaml中代码: <Canvas > <ContentPresenter Content="{Binding Canvas}"/> </Canvas> 在对应的ViewModel类中添加属性Canvas即可
阅读全文
摘要:<WebBrowser Source="https://www.cnblogs.com/follow-discoverer/p/17431492.html" /> 我这边的问题是主窗口界面设置了AllowTransparent=true,去掉这行代码,改用Resizemode=”CanResizeW
阅读全文
摘要:直接上代码 public void ChangeColorStyle() { ResourceDictionary resource=new ResourceDictionary(); for(int i=0;i<Appliation.Current.Resources.MegedDictionar
阅读全文
摘要:1 public static void ExportToPng(this Canvas canvas,Uri path) 2 { 3 if(path==null) 4 { 5 return; 6 } 7 Transform transform =canvas.LayoutTransform; 8
阅读全文
摘要:代码如下 private ObservableCollection<string> fruits=new ObservableCollection<string>{"苹果","西瓜"}; ObservableCollection<string> Fruits{ get{ return fruits;
阅读全文
摘要:wpf应用中,从父窗体新建并打开了一个子窗体。想让子窗体显示在父窗体居中位置。会在子窗体xmal里window标签中添加 windowStartupLocation=“CenterOwner”。 然后在父窗体中 ChildWindow cw=new ChildWindow(); cw.Owner=t
阅读全文