如果您运行此代码并最小化/最大化窗口的宽度
<TextBlock TextTrimming="WordEllipsis" >
<Run Text="I want that this rectangle will be placed "/>
<Rectangle Fill="Black" Width="20" Height="10" />
<Run Text=" here when I minimize width of the window"/>
</TextBlock>
Run Code Online (Sandbox Code Playgroud)
你会看到Rectange会转移到左侧.
是WPF中的错误吗?
不明确的行为,如果我声明类型:
struct Token
{
public static implicit operator int(Token x)
{
return 0;
}
public static implicit operator string(Token x)
{
return "";
}
}
Run Code Online (Sandbox Code Playgroud)
我们有两个隐式转换.如果我使用工作文件
var t = new Token();
if (t == "123")
{
}
Run Code Online (Sandbox Code Playgroud)
CS0151:开关表达式或大小写标签必须是bool,char,string,integral,enum或相应的可空类型
如果我使用:
switch (t)
{
case "123" :
{
break;
}
}
Run Code Online (Sandbox Code Playgroud)
但如果我删除int隐式转换,则错误消失.
struct Token
{
public static implicit operator string(Token x)
{
return "";
}
}
Run Code Online (Sandbox Code Playgroud)
它是编译器中的错误还是正确的行为?