调试工具
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中会发生什么奇妙的现象了?
<DataTemplate DataType="{x:Type system:String}">ToolTip会变成这样,Button会变成一条线。
<StackPanel>
<Image Source="{Binding }" MinHeight="500" MaxHeight="600" MaxWidth="800" />
</StackPanel>
</DataTemplate>