相关疑难解决方法(0)

如何在multibinding中获取父值

我正在使用dataTemplate.这是模板:

   <ItemsControl ItemsSource="{Binding RAM.Partitions}">
        <ItemsControl.ItemTemplate>
            <DataTemplate>
                <Grid>
                    <TextBlock Text="{Binding Position, StringFormat={}{0}k}"/>
                    <Grid Grid.Column="1">
                        <Border>
                            <Border.Height>
                                <MultiBinding Converter="{StaticResource MultiplyConverter}">
                                    <Binding ElementName="LayoutRoot" Path="ActualHeight"/>
                                    <Binding Path="Size" />
                                    <Binding Path="RAM.Size" />
                                </MultiBinding>
                            </Border.Height>
                        </Border>
                    </Grid>
                </Grid>
            </DataTemplate>
        </ItemsControl.ItemTemplate>
    </ItemsControl>
Run Code Online (Sandbox Code Playgroud)

你能看到这条线吗?

<Binding Path="RAM.Size" />
Run Code Online (Sandbox Code Playgroud)

该行引发了一个异常,它应该是因为RAM.Size来自父元素.我怎么能得到那个价值?

提前致谢!

c# data-binding wpf binding datatemplate

13
推荐指数
1
解决办法
1万
查看次数

标签 统计

binding ×1

c# ×1

data-binding ×1

datatemplate ×1

wpf ×1