我一直在谷歌搜索这个问题几个小时,我遇到的最好的事情是ItemContainerGenerator,这不是我需要的
在我的主视图中,我有一个ItemsControl,它绑定到一个对象集合:
<ItemsControl ItemsSource="{Binding Path=Concepts}"
ItemTemplate="{StaticResource ActivationLevelTemplate}"
/>
Run Code Online (Sandbox Code Playgroud)
ActivationLevelTemplate只是另一个视图:
<DataTemplate x:Key="ActivationLevelTemplate">
<view:ConceptActivationView Height="50"/>
</DataTemplate>
Run Code Online (Sandbox Code Playgroud)
在此视图中,有一个文本块,绑定到上述集合中对象的属性.该属性显示正确,现在我需要从视图的代码后面访问同一对象的其他属性.这似乎微不足道,但我无法让它发挥作用.
<TextBlock Text="{Binding Path=Name}"
HorizontalAlignment="Center"
/>
<d3:Plotter2D Name="Plotter"/>
Run Code Online (Sandbox Code Playgroud) 我试图重载乘法运算符以方便缩放2D精灵,但似乎其中一个操作数必须是包含类型.这是一个遗憾,因为我发现我的解决方案不合逻辑.另外,我发现应该在其中一个操作数的类声明中声明这样的运算符重载.那么,我是否必须创建自己的自定义SuperRectangle类或者有一些解决方法?
public static Rectangle operator * (Rectangle rect, Vector2 scale)
{
return new Rectangle(rect.X, rect.Y, (int)(rect.Width * scale.X), (int)(rect.Height * scale.Y));
}
Run Code Online (Sandbox Code Playgroud)