如何获取由Binding生成的元素的宽度?

我生成一个带有- name: Assemble from fragments from a directory assemble: src: /my/remote/ dest: /my/remote/dst Initial: # ls file1 file2 # cat file1 this is file1 # cat file2 this is file2 After running playbook: # cat dst this is file1 this is file2 的元素列表。 但是我需要参考列表中的绑定项来了解单个控件的ObservableList

我需要ItemsControl来削减我的actualWidth,以使其不超过Width

我尝试使用Polyline属性将CanvasOneWayToSource绑定回列表中的项目。始终为NaN或0。

TwoWay

以及绑定对象的类

Width

我希望<ItemsControl x:Name="GraphLB" ItemsSource="{Binding}"> <ItemsControl.ItemTemplate> <DataTemplate> <Border Padding="5,5,0"> <StackPanel> <TextBlock Text="{Binding Text}" Foreground="{Binding Foreground}"/> <Border BorderBrush="{Binding Foreground}" BorderThickness="0.5"> <Canvas MinHeight="40" MinWidth="100" Height="{Binding Height,Mode = TwoWay }" Width="{Binding Width,Mode = TwoWay }"> <Polyline Points="{Binding Line}" Stroke="{Binding Foreground}" StrokeThickness="1"/> </Canvas> </Border> </StackPanel> </Border> </DataTemplate> </ItemsControl.ItemTemplate> </ItemsControl> 会将列表元素中的值设置为class GraphListObject : LabelListObject { public double Height { get; set; } public double Width { get; set; } private getProperty<PointCollection> getLine; public PointCollection Line { get { return GetLine(); } } internal getProperty<PointCollection> GetLine { get => getLine; set { getLine = value; } } } 元素的宽度,但实际输出为0。

可悲的是,Width="{Binding Width,Mode = TwoWay }"被绘制在边界之外:

如何获取由Binding生成的元素的宽度?

liunina123 回答:如何获取由Binding生成的元素的宽度?

暂时没有好的解决方案,如果你有好的解决方案,请发邮件至:iooj@foxmail.com
本文链接:https://www.f2er.com/3118413.html

大家都在问