简体   繁体   English

图像绑定双向模式不起作用 wpf c#

[英]Image binding two way mode not working wpf c#

i have an image tag in my window, whenever i am binding it in one way mode, its working fine, but unable to two way mode.我的窗口中有一个图像标签,每当我以单向模式绑定它时,它都可以正常工作,但无法以双向模式进行绑定。

<ComboBox Grid.Column="1" DisplayMemberPath="sm.admno"  Grid.Row="0" Name="txtadm" ItemsSource="{Binding}" IsSynchronizedWithCurrentItem="True" IsEditable="True"/>
<Image Grid.Column="6" Grid.Row="0"  Source="{Binding ElementName=txtadm, Mode=TwoWay, Path=SelectedItem.sp.pic, UpdateSourceTrigger=PropertyChanged}" Grid.RowSpan="4" Grid.ColumnSpan="2" Name="imgpic"/>

class i am using我正在使用的课程

public string admno { get; set; }
public byte[] pic { get; set; }

data binding souce数据绑定源

var dt = from sm in db.studentmains
         join sp in db.StudentPersonals on sm.admno equals sp.admno
         select new { sm, sp};
txtadm.ItemsSource = dt.ToList();

Image.Source is not a property for which TwoWay makes any sense, the control is not interactive, it's not going to change the source. Image.Source不是TwoWay有任何意义的属性,控件不是交互式的,它不会改变源。 If you modify it, you should modify the data, not the Image.Source .如果你修改它,你应该修改数据,而不是Image.Source

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM