« first day (1316 days earlier)      last day (2833 days later) » 

12:14 PM
Good morning!
 
12:29 PM
waves
 
waves back over the cubicle
 
12:52 PM
Is it possible to use MouseBinding technique described here on a row of a ListView to detect double-click? stackoverflow.com/a/6882619/177416
I'd like to show details of a record in a Material Design dialog on double-click of the row
The third answer on that same question provides a better approach... using <i:Interaction.Triggers>
 
1:30 PM
And yet, it's 152 votes behind.
 
1:50 PM
@Alex I use mousebinding on all of my Listboxes
<DataTemplate>
      <Grid MinWidth="400" MinHeight="32">
              <Grid.InputBindings>
                      <MouseBinding Gesture="LeftDoubleClick"  CommandParameter="{Binding}" Command="{Binding DataContext.DoStuffCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" />
               </Grid.InputBindings>
^ ListBoxItem template
 
@LynnCrumbling Thanks! Never done it before, so wasn't sure if it's available inside an LV item
 
Not sure about LV, but it's probably just like LB
 
What I also need to do is determine the row that was double-clicked -- basically, get a reference to it. The LV is going to be bound to an OC of VMs, so each row is a VM
Would that be available in the SelectedItem?
 
Right - that template I showed is for the ListBoxItem -- if you notice, the command passes a CommandParameter of {Binding}
{Binding} will be set to the current child row DataContext
 
Ahhh... So it's binding to the default, which is a row
Nice!
Thanks :)
 
1:54 PM
Yep, when Command is called, it'll be passed the DC of the child as an arg.
 
And you set the RelativeSource because you want it to walk up the hierarchy to the usercontrol
Where the command resides in that DataContext
 
Exactly.
 
Just what I needed!
 
Feel free to change UserControl -> Window if your command lives there instead.
 
I'm using a view (UserControl) so it's fine
Another question... How would the RelayCommand receive the parameter in the VM?
public RelayCommand OpenTestDialogRelayCommand { get; private set; }
In the ctor: OpenTestDialogRelayCommand = new RelayCommand(OpenTestDialog);
 
2:05 PM
Alex, take a look at OpenTestDialog method declaration and you'll see :)
 
Got it!
public ICommand OpenTestDialogRelayCommand => new RelayCommand<SimpleTestViewModel>(OpenTestDialog);
private void OpenTestDialog(SimpleTestViewModel simpleTestVm)
{
	// do something
}
 
Exactly.
 
:)
First time using RelayCommand that takes a parameter!
 
SimpleTestViewModel would be that data structure that the OC is composed of.
 
Yep
 
2:21 PM
morning folks!
You can now all call me SQL MASTER! ;)
 
'morning Markus
 
2:37 PM
is it a good thing to be a "SQL MASTER" ?
 
One of the best titles to have, IMO :)
 
Well, I haven't had it for long (lets say <1 hour) so I haven't seen any of the perks yet...
 
Of course, in IT, you touch it, you own it. So if word gets around that you know SQL, all those tasks will come your way in the office
 
 
1 hour later…
4:11 PM
hey
 
hey
 
When a menu pops up, shouldn't it invoke the ICommands CanExecute to disable the menu items automatically?
It seems to be called when I click, but not when the menu opens
 
like context menu, or like menu menu?
 
Context Menu
Right click menu
:)
 
ahh. i've had similar issues. I think there is a call that needs to be made to force update, cause ICommand won't update like you think it should.
CommandManager or something of that nature
 
4:18 PM
Oh?
Hmm
thats annoying lol
 
86
Q: WPF - How to force a Command to re-evaluate 'CanExecute' via its CommandBindings

Drew NoakesI have a Menu where each MenuItem in the hierarchy has its Command property set to a RoutedCommand I've defined. The associated CommandBinding provides a callback for the evaluation of CanExecute which controls the enabled state of each MenuItem. This almost works. The menu items initially com...

 
When am I supposed to call it?
		public ICommand OpenContainingFolderCommand
		{
			get
			{
				return new DelegateCommand(
						(args) =>
						{
							Process.Start("explorer.exe", "/select," + Asset.Path);
						}, _o => File.Exists(Asset.Path));
			}
		}
infact my problem seems different
i know what it is now
 
 
1 hour later…
5:40 PM
@ReedCopsey how was it that you get around having to call CommManager.InvalidateRequerySuggested or whatever
isn't there a special ICommand implementation out there for it
 
5:59 PM
@Kevin Tha'ts the built in way of doing things, but in general, it's more trouble than it's worth
it's (marginally) useful if you're using routed commands
but for delegate based ones, it tends to be problematic
you don't need to do that - if you don't use command manager in your command impl, you can just raise CanExecuteChagned directly on the command
see my pinned command implementation - it has the option of doing either ;)
 
6:18 PM
Important safety tip: Ensure you spell your properties correctly when binding in XAML!
Finally noticed the error in the output window that it couldn't find the property. Misspelled paramter -- should be parameter. Had it correct in the XAML wrong in the VM
 
you can set the data context type in xaml to get intelisense on your bindings
 
Yep, did it in some views but forgot on this one
Just added DC to view and it's giving me InteliSense
Nice
But then it instantiates a new VM and binds it to the view... In this situation, where I'm showing the details of a ListView row when the user selects an item, it shows me a view with all blank properties instead of the SelectedTest:
<ListView
	ItemTemplateSelector="{StaticResource TestDataTemplateSelector}"
    ItemsSource="{Binding Tests}"
    SelectedItem="{Binding SelectedTest}"> ... </ListView>

<ContentControl Content="{Binding SelectedTest}"
	ContentTemplateSelector="{StaticResource TestDataTemplateSelector}" />
 
6:52 PM
err. i dont think those things have anything to do with each other
 
I must be doing something wrong
 
you didnt implement INPC on SelectedTest
your ListView and your ContentControl have different DataContexts
your SelectedItem actually has blank properties
 
None of those are true, as far as I can see. But when I add the <UserControl.DataContext>, clicking a row in the LV gives me blank view fields. Take it out and everything works well. For now, I'm going to add the DC to the view only for Intellisense and take it out after
 
are you usin gdesign time data contextx?
ie: <d:DataContext> ?
or setting the normal one?
 
The DC is being set via the ContentControl's Content DP to point to SelectedTest (code is above)
 
7:32 PM
no i think reed is trying to say you are confusing assigning a data context via xaml vs assigning the data context type via xaml
 
Ohhh
How do you set the type?
I've been actually setting the DC itself
smacking my head
 
i actually dont do it often, and google doesnt seem to have great example results
doesnt seem terrible
 
d:DataContext="{d:DesignInstance vm:TechnicianSelectionViewModel}"
 
Yeah, I was getting the type and instance confused
Went with this:
d:DataContext="{d:DesignInstance {x:Type vm:AlcoholTestViewModel},
	IsDesignTimeCreatable=True}"
What does the IsDesignTimeCreatable do?
 
7:55 PM
if you set it to false
the runtime will make you a "fake" type that matches the "shape" of that class
 
Hmm. Wow!
Interesting stuff :)
Yep! It works like a charm
 
8:53 PM
Have a good weekend, all
 
thanks, too
 

« first day (1316 days earlier)      last day (2833 days later) »