|
The user control element that is supposed to show the update is bound to the item (which is the data context). The UI does in fact update, but not while any of the 5 items is processing
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
I want to collapse or expand all TreeView nodes under parent node if user holds down Left Control key and presses left mouse button on expansion arrow of tree view.
How do you do this in WPF? It's not as obvious as it was in WinForms.
|
|
|
|
|
|
As Gerry mentioned, you need to hook up a handler for the mouse click and check the status of the CTRL key.
You then go through all your child ViewModels and flip the property you databound to the IsExpanded property.
This is how you can databind the IsExpanded property (and take IsSelected along for the ride if you need it - makes it VERY easy to select an item programmatically):
<TreeView.ItemContainerStyle>
<Style TargetType="{x:Type TreeViewItem}">
<Setter Property="IsExpanded" Value="{Binding Path=IsExpanded, Mode=TwoWay}"/>
<Setter Property="IsSelected" Value="{Binding Path=IsSelected, Mode=TwoWay}"/>
</Style>
</TreeView.ItemContainerStyle>
In case you do not have a view model for your tree items you have two options:
1. Switch to WinForm
2. Introduce the view model
I supposed you could also try calling methods on the tree view control itself to find it's children, but it will be a LOT more code than the viewmodel, specifically when it start delay loading and virtualizing etc. WPF was designed for a ViewModel, and going against that is always asking for pain.
|
|
|
|
|
Hi,
I want to create a project with AvalonDock and MVVM based on the example of AvalonDock and MVVM of Ashley Davis.
I want to use the AValonDock.ManagedContent class (AvalonDock component) but in the Dirkster AvalonDock package (Dirkster99 · GitHub) the ManagedContent class in not present.
Is there a workaround or an equivalent class ?
Thanks for the answers.
|
|
|
|
|
It's been 10 years ... time marches on.
AvalonDock and MVVM
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
Hi Gerry,
Thanks for the answer.
I'm read the "AvalonDock and MVVM" project of Ahsley Davis. He uses ManagedContent class of Avalon (especially in dico Dictionary<object, managedcontent=""> contentMap, ..),
but in the new AvalonDock version (of Dirkster99 Avalon free support release),
i notice that this class MangedContent does not exist.
If there is no bypass, I will do it another way (based on the Avalon example MVVMTestApp that comes with the AvalonDock source code).
Regards.
|
|
|
|
|
I'm using MahApps in my app. The data grid's column header style looks like this.
So I added this to my cell headers:
<DataGridTextColumn.HeaderStyle>
<Style TargetType="DataGridColumnHeader">
<Setter Property="HorizontalContentAlignment"
Value="Center" />
</Style>
</DataGridTextColumn.HeaderStyle>
The problem is that now the column headers have lost their style. It now looks like this
How can I apply the header alignment without loosing my grid styling?
Thanks
If it's not broken, fix it until it is.
Everything makes sense in someone's mind.
Ya can't fix stupid.
|
|
|
|
|
Use BasedOn.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
So I have this ListView , and I want to make a specific column have a different font family, so I tried setting the CellTemplate for the column. Because of the architecture of the app, I have to apply this template in the C# code.
I tried :
- Creating a resource like so:
<DataTemplate x:Key="PAScodeGridCell" >
<TextBlock Text="{Binding}" FontFamily="Consolas" />
</DataTemplate>
and was setting it like so:
column.CellTemplate = (DataTemplate)WpfCommon.Globals.XamlReaderLoad("PAScodeGridCell"); It found the template in the resource file, and set it to the CellTemplate property, but the font in that column wasn't Consolas.
Next, I tried so I tried specifying the template as a string in the c# code like so:
readonly string _CELL_TEMPLATE_ = string.Concat( "<DataTemplate xmlns=\"http://schemas.microsoft.com/winfx/2006/xaml/presentation\">",
"<TextBlock ",
"Text=\"{{Binding Path=PAScode}}\" ",
"FontFamily=\"Consolas\" /></DataTemplate>", and set the property like so
column.CellTemplate = (DataTemplate)XamlReader.Load(xaml);
The result was no different.
By all rights, both methods should have worked. I inspected the visual tree while the app was running and it's as if the specified template wasn't applied at all.
What am I don't wrong?
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
|
I think I posted the wrong snippet for the first attempt. I used FindResource there.
No matter which way I tried it, the CellTemplate showed that it was set, but the column did not reflect the settings I was trying to set.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
I found the problem. This is the code that was creating the GridViewColumn:
DataTemplate cellTemplate =
Binding binding = new Binding()...
GridViewColumn column = new GridViewColumn()
{
Header = "...",
DisplayMemberBinding = binding,
CellTemplate = cellTemplate,
};
I had to change it to NOT set the DisplayMemberBinding property:
GridViewColumn column = new GridViewColumn()
{
Header = "...",
DisplayMemberBinding = (celltable == null) ? binding : null,
CellTemplate = cellTemplate,
};
And now it does exactly what I want it to do.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Glad it's working.
Might be a timing thing:
Quote: Resources can also be referenced by code from within the collection, but be aware that resources created in XAML will definitely not be accessible until after Loaded is raised by the element that declares the dictionary.
(I see now you're "creating" on the fly; I was "switching" when I looked back at my app).
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
It's a binding thing - I was using DisplayMemberBinding, and then trying to apply a template that did its own binding - you can't do both, and when you try, it always does the DisplayMemberBinding first.
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
That makes sense.
It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it.
― Confucian Analects: Rules of Confucius about his food
|
|
|
|
|
I have an icon (resource, do not copy) in my project.
I added an Image element to my xaml.
<Image Source="pack://application,,,/Pilot128.ico" Height="24" />
The icon shows up in the designer, but not when I actually run the app.
However, when I do this, it works as expected:
<Window.Resources>
<BitmapImage x:Key="appIcon" UriSource="Pilot128.ico" />
</Window.Resources>
<Image Source="{StaticResource appIcon}" Height="24" />
Why doesn't the first way work?
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
Have you tried either:
<Image Source="/Pilot128.ico" Height="24" /> or:
<Image Source="pack://application:,,,/YourAssemblyName;component/Pilot128.ico" Height="24" /> The documentation[^] seems to suggest that your URI should work, but I don't think I've ever managed to make it work.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yeah, they both do the same thing.
I guess I'm fine with what I have to do to get this to work, but it doesn't make any sense that I *have* to do that way, unless it's because it's an ICO file as opposed to a png/jpg?
".45 ACP - because shooting twice is just silly" - JSOP, 2010 ----- You can never have too much ammo - unless you're swimming, or on fire. - JSOP, 2010 ----- When you pry the gun from my cold dead hands, be careful - the barrel will be very hot. - JSOP, 2013
|
|
|
|
|
|
When does the next tick start. Watching how things seem to preform it seems like:
Tick
Execute Tick routine, pause tick timer
Tick routine ends, restart tick timer
It seems like the tick interval is between the tick routines. It is OK, I just want to make sure I understand it correctly.
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
You have the sequence wrong!
Tick
Stop the timer
process the tick routine
restart the timer.
If your process is longer than the timer interval it clags up the system.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
That's what I meant. Maybe I did not state it well.
"it clags up the system" is what I thought at first but it seems to follow the above sequence fairly well. As I change the tick interval it seems to be offset by a constant. My tick routine has to read some USB analog inputs. It is slow but consistent.
I cannot find anything on the web to explain clags.
So many years of programming I have forgotten more languages than I know.
|
|
|
|
|
Sorry - slang
You end up with queued processes that are re-launched before the last one is completed therefore you need to insure that only 1 process is launched at a time.
Never underestimate the power of human stupidity -
RAH
I'm old. I know stuff - JSOP
|
|
|
|
|
I like the slang better.
So many years of programming I have forgotten more languages than I know.
|
|
|
|