c# - How to display a child window on grid cell click using SelectedItem (mvvm approach) -


I am starting a C # Silverlight and I have to use the MVVM approach to achieve my work. I have already created a GUI that looks like this:

http: // prntscr .com / 3c6ak5 & lt; UserControl x: class = "DEV_CENTER.MainPage" xmlns = "http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns: x = "http://schemas.microsoft.com/winfx/ 2006 / xaml "xmlns: D =" http://schemas.microsoft.com/expression/blend/2008 "xmlns: mc =" http: //schemas.openxmlformats .org / markup-compatibility / 2006 "xmlns: vm = "Clr-namespace: DEV_CENTER" xmlns: data = "clr-namespace: System.Windows.Controls; assembly = System.Windows.Controls.Data" mc: Ignorable = "D" D: DesignHite = "300" D: DesignView = "400" & gt; & Lt; UserControl.Resources & gt; & Lt; vm: ProgramView Model X: Key = "ProgramWell Mode" /> & Lt; /UserControl.Resources> & Lt; Grid X: Name = "Layouts" background = "White" & gt; & Lt; Data: Data Grid Grid Rau = "0" x: name = "grid program" automatically generated column = "wrong" item source = "{binding path = projector}" IsReadOnly = "True" DataContext = "{StaticResource ProgramViewModel}" & gt; & Lt; Data: DataGrid.Columns & gt; & Lt; Data: DataGridTextColumn header = "serial number" binding = "{binding path = serial number}" width = "2 *" & gt; & Lt; / Data: Data Grid Text Claul & gt; & Lt; Data: DataGridTextColumn header = "Firstname" binding = "{binding path = first name}" width = "2 *" & gt; & Lt; / Data: Data Grid Text ClauL & gt; & Lt; Data: DataGridTextColumn header = "last name" binding = "{binding path = last name}" width = "3 *" & gt; & Lt; / Data: DataGrade Text column & gt; & Lt; / Data: DataGrid.Columns & gt; & Lt; / Data: Data grid & gt; & Lt; / Grid & gt; & Lt; / UserControl & gt; Now, by clicking on " sso " and " Program 2 ", you will need to create a hair window by clicking another hair window. Just below the heading ( serial number ). There will also be a few buttons and text boxes in the child window.

Where should I change to do this? I have to use the MVVM approach to do this. Using the correct method of "selection list", How can I bind it if I use "selection list" and how to link it to Model.cs and ViewModel.cs? Can anyone help me give a piece of code for ViewModel.cs and Model.cs and View.xaml? Thanks a big help

Note: Please note that I do not need Gala and any third library (I like to use the chosen EITM) < / Div>

I think what you are trying to do by using DataGridTemplateColumn as shown here < Pre> & lt; DataGrid.Column & gt; & Lt; DataGridTemplateColumn Header = "Serial Number" & gt; & Lt; DataGridTemplateColumn.CellTemplate & gt; & Lt; DataTemplate & gt; & Lt; TextBlock x: name = "btnsierial number" text = "{binding serial number}" previewmax leftbuttondown = "btnsierialnumber_click" /> & Lt; / DataTemplate & gt; & Lt; /DataGridTemplateColumn.CellTemplate> & Lt; / DataGridTemplateColumn & gt; & Lt; /DataGrid.Columns> Add style to your control resource by using

or style, targeting datagridel shown in

  & lt ; Style TargetType = "{x: type datagridel}" x: key = "datagridclickclick style" & gt; & Lt; EventSetter Event = "PreviewMouse LeftBitDowndown" Handler = "Data GridSelfPiewWasmsMootBootdowndown" & gt; & Lt; / EventSetter & gt; & Lt; / Style & gt;   

and then add the cellstyle and the above created datagridclassClickstyle

  & lt; Refer to DataGridTextColumn header = "SerialNumber" binding = "{binding path = serial number}" width = "2 *" cellstyle = {static resource datagridclickclic style} "/>   

DataGridTemplateColumn Be sure to use or apply the style to serial number columns only. Then within the btnSerialNumber_Click or DataGridCell_PreviewMouseLeftButtonDown event handler, you can get exact cells and objects that are bound to it, and then you can launch another window

Comments

Popular posts from this blog

Pass DB Connection parameters to a Kettle a.k.a PDI table Input step dynamically from Excel -

multithreading - PhantomJS-Node in a for Loop -

c++ - MATLAB .m file to .mex file using Matlab Compiler -