c# - "Thickness"的 TypeConverter 不支持从字符串转换

标签 c# .net xaml silverlight-5.0

我正在为 silverlight xaml 文件使用以下代码。

<UserControl x:Class="DBServer.Selenium.Silvernium.ReferenceApplication.SilverlightFixture"    
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" 
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:navigation="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Navigation" 
             mc:Ignorable="d" 
             d:DesignWidth="640" 
             d:DesignHeight="480">
    <navigation:Frame x:Name="frameContent" Source="/MainPage.xaml" Margin="0,0,0,0"/> // "Margin" on this line throws error
</UserControl>

但是当我尝试构建它时抛出以下错误

The TypeConverter for "Thickness" does not support converting from a string

最佳答案

尝试了你的代码,它没有抛出任何错误,你确定它在 xaml 而不是运行给出该错误的代码的 xaml.cs 文件中,因为 Thickness 是你在运行代码中定义边距的方式像这样

mainborder.Margin = new Thickness(20, 20, 20, 20);

关于c# - "Thickness"的 TypeConverter 不支持从字符串转换,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21689972/

相关文章:

.net - WPF 图像 UriSource、数据绑定(bind)和缓存

c# - 带参数的 slider 的 ThumbToolTipValueConverter

c# - Wpf Listview不显示数据

c# - 从 .NET 中的堆栈帧获取参数值?

c# - 如何实现返回类型为 Task<T> 的方法

c# - C# 和 VB.Net 之间对象装箱/比较引用的差异

c# - 缺少手机状态栏

c# - default(IEnumerable<T>) 的值是多少?

c# - 反射调用列表中的类中的方法

c# - Wix 安装项目的 exe "app can' t 在您的 PC 上运行”