在列表视图中显示所选数据 [英] Display selected data in list view

查看:76
本文介绍了在列表视图中显示所选数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有两个窗口,一个有访问者列表,另一个用于显示它。如果我选​​择一个访问者(例如SUNDAR)并显示在另一个页面上如何显示



Xaml访客



 <   ListView     x:名称  =  listVisitor      ItemsSource   =  {Binding}    Horizo​​ntalAlignment   =  Left   高度  =  582   保证金  =  110,65,0,0    VerticalAlignment   = 顶部    Width   =  924    Grid.ColumnSpan   =  3     /  >  

< 按钮 内容 = 查看Visi tor 前景 < span class =code-keyword> =
white Horizo​​ntalAlignment = 保证金 = 98,674,0 ,0 VerticalAlignment = Top 宽度 = 320 高度 = 30 背景 = #FF1CA0B7 Grid.ColumnSpan = 2 名称 = ViewBtn 点击 = ViewBtn_Click < span class =code-attribute> / >





代码



<前lang =c#> private void ViewBtn_Click( object sender,RoutedEventArgs e)
{
ViewList dialogBox = new ViewList();`
Nullable< bool> dialogResult = dialogBox.ShowDialog();

}





Xaml Viewlist



 <   TextBox      名称  =  VisitorNo  /  >  
< span class =code-keyword>< TextBox 名称 = 名称 / >





code



  private   void  VisitorNo_TextChanged( object 发​​送呃,TextChangedEventArgs e)
{

}

private void Name_TextChanged( object sender,TextChangedEventArgs e)
{

}



我已经从访客数据库建立连接

如何在两个文本框中显示?

解决方案

< blockquote>你需要在PRISM中使用EventAggretators。



在一个窗口中选择一个值后。该值将绑定到视图模型中的属性。



将所选值作为事件对象中的参数发布。



在其他窗口中视图模型侦听/订阅事件并从事件对象参数中获取值。将值绑定到该窗口中所需的依赖项属性,以便该值反映在UI中。



对于视图模型和这种场景之间的通信,我们需要使用evenaggregators。


I have two window,one have list of visitor,another to display it.How to display if I select one visitor(example SUNDAR) and display back on another page

Xaml Visitor

<ListView x:Name="listVisitor"  ItemsSource="{Binding}" HorizontalAlignment="Left" Height="582" Margin="110,65,0,0" VerticalAlignment="Top" Width="924" Grid.ColumnSpan="3" />

   <Button Content="View Visitor"  Foreground="white" HorizontalAlignment="Left" Margin="98,674,0,0" VerticalAlignment="Top" Width="320" Height="30" Background="#FF1CA0B7" Grid.ColumnSpan="2" Name="ViewBtn" Click="ViewBtn_Click" />



Code

private void ViewBtn_Click(object sender, RoutedEventArgs e)
    {
        ViewList dialogBox = new ViewList();`
        Nullable<bool> dialogResult = dialogBox.ShowDialog();

    }



Xaml Viewlist

<TextBox  Name="VisitorNo"/>
<TextBox Name="Name"/>



code

private void VisitorNo_TextChanged(object sender, TextChangedEventArgs e)
   {

   }

   private void Name_TextChanged(object sender, TextChangedEventArgs e)
   {

   }


I already make connection from database for Visitor
How to display at both textbox?

解决方案

You need to use EventAggretators in PRISM.

Once a value is selected in one window.The value will be binded to a property in the view model.

Publish the event with that selected value as a parameter in event object.

In the other window's view model listen/subscribe to the event and get the value from the event object parameter. Bind the value to the required dependency property in that window so that the value gets reflected in UI.

For communication between view models and this kinds of scenarios we need to use evenaggregators.


这篇关于在列表视图中显示所选数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆