WPF 绑定 Grid.Column 属性
我需要通过转换器设置项目的 Grid.Column 属性。 这是我的 xaml:
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Periodo.Inizio}">
<Grid.Column>
<MultiBinding Converter="{StaticResource ItemColumnSetter}">
<Binding RelativeSource="{RelativeSource Self}" />
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=local:Timeline}" Path="StartDate" />
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=local:Timeline}" Path="EndDate" />
<Binding Path="Periodo.Inizio" />
</MultiBinding>
</Grid.Column>
</TextBlock>
</DataTemplate>
</ItemsControl.ItemTemplate>
但不起作用。 我确信转换器工作得很好......
I need to set Grid.Column property of an item by a converter.
this is my xaml :
<ItemsControl.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding Periodo.Inizio}">
<Grid.Column>
<MultiBinding Converter="{StaticResource ItemColumnSetter}">
<Binding RelativeSource="{RelativeSource Self}" />
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=local:Timeline}" Path="StartDate" />
<Binding RelativeSource="{RelativeSource Mode=FindAncestor, AncestorType=local:Timeline}" Path="EndDate" />
<Binding Path="Periodo.Inizio" />
</MultiBinding>
</Grid.Column>
</TextBlock>
</DataTemplate>
</ItemsControl.ItemTemplate>
But don't work.
I'm sure that the converter work well...
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您的 TextBlock 将被包装在某种类型的另一个控件中,这意味着任何 Grid.XXX 属性都将被忽略。要正确应用这些,您需要在
ItemsControl.ItemContainerStyle
中进行绑定。应该是这样的:
Your TextBlock will be wrapped in another control of some sort, that means any
Grid.XXX
properties will be disregarded. To apply those properly you need to do the binding in theItemsControl.ItemContainerStyle
.Should be something like this: