[WPF系列] 高级 调试

调试工具

image

 

ImageBrush出现TypeConverter问题

'Provide value on 'System.Windows.Baml2006.TypeConverterMarkupExtension' threw an exception.' Line number '49' and line position '38'

 

Assuming the image is:

  • Included in your project
  • It's in a folder named "Images"
  • The build action for the image is set to "Resource" (should be the default)

You can reference it like this:

<ImageBrush ImageSource=
   "pack://application:,,,/YourProjectName;component/Images/wood1_1000X1000.jpg";

 

This fixed the issue, I put the image in the project folder whithout including it in the project itself.

 

 

Width与MaxWidth的区别

当你所要控制的对象,宽度或者高度值总是变化,而不是你想要指定的固定值,那么很有可能设置成了MaxHeight(MaxWidth)

 

Label等其他控件字体颜色修改不了

这个是很有可能是定义一个全局的TextBook,且没有指定该Style的Key值。导致Label等控件的字体大小颜色无法修改。

 

模板虽好但莫随意使用

实例:试想下如果你将如下代码定义到你到的Resource中会发生什么奇妙的现象了?

1
2
3
4
5
<DataTemplate DataType="{x:Type system:String}">
           <StackPanel>
               <Image Source="{Binding }" MinHeight="500" MaxHeight="600" MaxWidth="800" />
           </StackPanel>
       </DataTemplate>
ToolTip会变成这样,Button会变成一条线。

WPFToolTips

posted @   霍旭东  阅读(1106)  评论(4编辑  收藏  举报
编辑推荐:
· DeepSeek 解答了困扰我五年的技术问题
· 为什么说在企业级应用开发中,后端往往是效率杀手?
· 用 C# 插值字符串处理器写一个 sscanf
· Java 中堆内存和栈内存上的数据分布和特点
· 开发中对象命名的一点思考
阅读排行:
· DeepSeek 解答了困扰我五年的技术问题。时代确实变了!
· PPT革命!DeepSeek+Kimi=N小时工作5分钟完成?
· What?废柴, 还在本地部署DeepSeek吗?Are you kidding?
· 赶AI大潮:在VSCode中使用DeepSeek及近百种模型的极简方法
· DeepSeek企业级部署实战指南:从服务器选型到Dify私有化落地
点击右上角即可分享
微信分享提示