|
Apologies for the shouting but this is important.
When answering a question please:
- Read the question carefully
- Understand that English isn't everyone's first language so be lenient of bad spelling and grammar
- If a question is poorly phrased then either ask for clarification, ignore it, or mark it down. Insults are not welcome
- If the question is inappropriate then click the 'vote to remove message' button
Insults, slap-downs and sarcasm aren't welcome. Let's work to help developers, not make them feel stupid.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
For those new to message boards please try to follow a few simple rules when posting your question.- Choose the correct forum for your message. Posting a VB.NET question in the C++ forum will end in tears.
- Be specific! Don't ask "can someone send me the code to create an application that does 'X'. Pinpoint exactly what it is you need help with.
- Keep the subject line brief, but descriptive. eg "File Serialization problem"
- Keep the question as brief as possible. If you have to include code, include the smallest snippet of code you can.
- Be careful when including code that you haven't made a typo. Typing mistakes can become the focal point instead of the actual question you asked.
- Do not remove or empty a message if others have replied. Keep the thread intact and available for others to search and read. If your problem was answered then edit your message and add "[Solved]" to the subject line of the original post, and cast an approval vote to the one or several answers that really helped you.
- If you are posting source code with your question, place it inside <pre></pre> tags. We advise you also check the "Encode "<" (and other HTML) characters when pasting" checkbox before pasting anything inside the PRE block, and make sure "Use HTML in this post" check box is checked.
- Be courteous and DON'T SHOUT. Everyone here helps because they enjoy helping others, not because it's their job.
- Please do not post links to your question into an unrelated forum such as the lounge. It will be deleted. Likewise, do not post the same question in more than one forum.
- Do not be abusive, offensive, inappropriate or harass anyone on the boards. Doing so will get you kicked off and banned. Play nice.
- If you have a school or university assignment, assume that your teacher or lecturer is also reading these forums.
- No advertising or soliciting.
- We reserve the right to move your posts to a more appropriate forum or to delete anything deemed inappropriate or illegal.
cheers,
Chris Maunder
The Code Project Co-founder
Microsoft C++ MVP
|
|
|
|
|
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.
|
|
|
|
|
You only need to pause, if the tick event takes longer to execute than the interval if you want a "proper" timer.
And if you're re-entrant, you don't need to pause either.
Pausing implies your interval is "off".
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
|
|
|
|
|
In my current way to structure a WPF-application I heavily lean on UserControls for my Views and place them in the MainWindow inside a container, usually a DockPanel. For instance in the MainWindow:
<DockPanel LastChildFill="True">
<views:Header DockPanel.Dock="Top" />
<views:Footer DockPanel.Dock="Bottom" />
<views:Body />
</DockPanel> For each View I have a corresponding ViewModel. This ViewModel is instantiated inside the View's XAMl-code. In the DataContext element. For instance in the Body View:
<UserControl.DataContext>
<vm:BodyViewModel />
</UserControl.DataContext> I like this approach, because I can alter any properties in the ViewModel and see the View automatically change in the view during design time.
But I have not find a good way to access any ViewModels from some class where I happened to need to alter the View through a property in a ViewModel.
My current solution - which I don't like - to gain access of the ViewModels is:
1. Give each View a name in the MainWindow.xaml file.
<DockPanel LastChildFill="True">
<views:Header DockPanel.Dock="Top" x:Name="viewHeader" />
<views:Footer DockPanel.Dock="Bottom" x:Name="viewFooter" />
<views:Body x:Name="viewBody" />
</DockPanel> 2. Do some logic in the MainWindow to setup the ViewModels for each View.
public partial class MainWindow : Window
{
HeaderViewModel Header { get; set; }
FooterViewModel Footer { get; set; }
BodyViewModel Body { get; set; }
public MainWindow()
{
InitializeComponent();
Header = viewHeader.DataContext as HeaderViewModel;
Footer = viewFooter.DataContext as FooterViewModel;
Body = viewBody.DataContext as BodyViewModel;
}
} 3. Then for every class where I need a ViewModel I need to pass it from the MainWindow in some way.class SomeClass
{
public void AlterHeaderText(HeaderViewModel header)
{
}
} This approach works, but I don't like it. It's annoying to pass ViewModels from the MainWindow every time a class need one or more ViewModels to alter a View.
Is there a solution to this approach to improve it?
/BR
Steffe
|
|
|
|