Click here to Skip to main content
15,883,847 members
Home / Discussions / WPF
   

WPF

 
QuestionUse dependency properties with a WPF custom control Pin
bytesport27-Mar-18 23:18
bytesport27-Mar-18 23:18 
Rant[REPOST] Use dependency properties with a WPF custom control Pin
Richard Deeming28-Mar-18 7:58
mveRichard Deeming28-Mar-18 7:58 
QuestionWPF DataGrid Group Summary Rows Pin
Kevin Marois19-Mar-18 17:26
professionalKevin Marois19-Mar-18 17:26 
AnswerRe: WPF DataGrid Group Summary Rows Pin
Mycroft Holmes19-Mar-18 21:58
professionalMycroft Holmes19-Mar-18 21:58 
GeneralRe: WPF DataGrid Group Summary Rows Pin
Kevin Marois20-Mar-18 5:01
professionalKevin Marois20-Mar-18 5:01 
GeneralRe: WPF DataGrid Group Summary Rows Pin
Mycroft Holmes20-Mar-18 12:29
professionalMycroft Holmes20-Mar-18 12:29 
AnswerRe: WPF DataGrid Group Summary Rows Pin
Gerry Schmitz20-Mar-18 8:14
mveGerry Schmitz20-Mar-18 8:14 
QuestionBind the Text property of a TextBlock inside a ListView inside a cell of a DataGrid to a ViewModel Pin
Mc_Topaz15-Mar-18 2:47
Mc_Topaz15-Mar-18 2:47 
The subject really say it all, even if it sounds over-complicated. Please hang on.

I have a DataGrid. There are several columns in the DataGrid.
One of the columns contains a ListView. The listView holds several rows.
Each row contains a TextBlock and a Button.
The TextBlock's Text property contains a name, which I want to pass to my ViewModel.

I have managed to create a small example of this which should be just to "copy-paste-run".
Since it is "a lot" of code I have made a public gist to store it in.
Link to source in GIT Gist[^]

Setup:
* I use Visual Studio 2015 and compiling to NET 4.5.2.
* I also use Fody.PropertyChanged, then I'm not needed to manually type all stuff required for the INotifyPropertyChanged interface.
* Create a new WPF application and call it: WpfTest.
* Save the project.
* Install the Fody.Propertychanged in the NuGet Package Manager.
* Create the FodyWeavers.xml file.
* Paste all code from the Gist.

Note:
If the compiler says: "Fody: Could not find a weaver named 'PropertyChanged'. ..."
Remove the <PropertyChanged /> from the FodyWeaver.xml file and try again. That line is not neccessary for this and I don't understand why it sometimes fail when compiling.

This is what I want
If you click any of the buttons in the DataGrid I want the associated name on the same row in the ListView to be bound to the SelectedName property in the ViewModel.
I have no clue how to do the binding of the selected Textblock's Text property to the ViewModel in the View's xaml code.
For example: Press the button to the right of NameA. I then want my ViewModels SelectedName to be "NameA".

I tried this in the ListView, but no luck:
HTML
<ListView ItemsSource="{Binding Names}" SelectedItem="{Binding SelectedName}">

I also tried this, with no luck:

HTML
<ListView ItemsSource="{Binding Names}" SelectedItem="{Binding Path=DataContext.SelectedName, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type DataGrid}}}">


Please, how can I do this?

P.S
I can kinda get this to work by binding the SelectedItem property from the DataGrid and the SelectedIndex property from the ListView. But that feels like a work-around.
AnswerRe: Bind the Text property of a TextBlock inside a ListView inside a cell of a DataGrid to a ViewModel Pin
Gerry Schmitz15-Mar-18 6:35
mveGerry Schmitz15-Mar-18 6:35 
QuestionWPF: GroupBox background Image Pin
Hervend8-Mar-18 22:01
Hervend8-Mar-18 22:01 
AnswerRe: WPF: GroupBox background Image Pin
Pete O'Hanlon8-Mar-18 22:44
mvePete O'Hanlon8-Mar-18 22:44 
GeneralRe: WPF: GroupBox background Image Pin
Hervend8-Mar-18 23:06
Hervend8-Mar-18 23:06 
GeneralRe: WPF: GroupBox background Image Pin
Hervend8-Mar-18 23:24
Hervend8-Mar-18 23:24 
GeneralRe: WPF: GroupBox background Image Pin
Hervend9-Mar-18 2:31
Hervend9-Mar-18 2:31 
AnswerRe: WPF: GroupBox background Image Pin
Leif Simon Goodwin8-Mar-18 22:47
Leif Simon Goodwin8-Mar-18 22:47 
AnswerRe: WPF: GroupBox background Image Pin
Leif Simon Goodwin8-Mar-18 22:49
Leif Simon Goodwin8-Mar-18 22:49 
GeneralRe: WPF: GroupBox background Image Pin
Hervend8-Mar-18 23:13
Hervend8-Mar-18 23:13 
GeneralRe: WPF: GroupBox background Image Pin
Leif Simon Goodwin9-Mar-18 0:38
Leif Simon Goodwin9-Mar-18 0:38 
QuestionPassing table value params to Sql Server from WPF app Pin
Christopher Duncan5-Mar-18 7:58
Christopher Duncan5-Mar-18 7:58 
AnswerRe: Passing table value params to Sql Server from WPF app Pin
Richard Deeming5-Mar-18 8:23
mveRichard Deeming5-Mar-18 8:23 
GeneralRe: Passing table value params to Sql Server from WPF app Pin
Christopher Duncan5-Mar-18 11:03
Christopher Duncan5-Mar-18 11:03 
GeneralRe: Passing table value params to Sql Server from WPF app Pin
Richard Deeming5-Mar-18 12:35
mveRichard Deeming5-Mar-18 12:35 
GeneralRe: Passing table value params to Sql Server from WPF app Pin
Christopher Duncan6-Mar-18 0:43
Christopher Duncan6-Mar-18 0:43 
GeneralRe: Passing table value params to Sql Server from WPF app Pin
Christopher Duncan6-Mar-18 1:23
Christopher Duncan6-Mar-18 1:23 
GeneralRe: Passing table value params to Sql Server from WPF app Pin
Richard Deeming6-Mar-18 1:29
mveRichard Deeming6-Mar-18 1:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.