|
This event fires for all parents of a certain treeviewitem. So if an item is on level n, then the event will fire n times.
Solution:
if (e.Source == tree.SelectedItem)<br />
DoSomething();
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
gajatko wrote: This event fires for all parents of a certain treeviewitem
The event bubbles up through the tree, but how were you getting all the events
at one handler?
Just curious
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
This way:
TreeViewItem item;
item.MouseDoubleClick += ...;
parentNode.Items.Add(item);
Rather standard procedure, isn't it? Or maybe it's another WTF WPF strange feature.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
So a parent item gets all of its child items' events, right?
What if the target item marks the event as handled?
gajatko wrote: Rather standard procedure, isn't it?
I'm asking you I'm wondering if I'm not understanding something correctly here.
Thanks,
Mark
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Here is a complete code:
private void AllToUI(MenuNode node, ItemCollection items)
{
foreach (MenuNode subNode in node.Nodes) {
NodeToUI(node, items);
if (subNode.Nodes.Count > 0)
AllToUI(subNode, items);
}
}
private void NodeToUI(MenuNode node, ItemCollection items)
{
TreeViewItem item = new TreeViewItem();
StackPanel itemContent = new StackPanel() {
Orientation = Orientation.Horizontal
};
item.Header = itemContent;
if (node.GetBitmap() != null)
itemContent.Children.Add(new Image {
Height = 20,
Source = node.GetBitmap()
});
Label content = new Label { Content = node.Header };
if (!System.IO.File.Exists(node.File))
content.Foreground = Brushes.Gray;
itemContent.Children.Add(content);
items.Add(item);
item.Expanded += new RoutedEventHandler(item_Expanded);
item.MouseDoubleClick += new MouseButtonEventHandler(item_MouseDoubleClick);
item.Tag = node;
}
void item_MouseDoubleClick(object sender, MouseButtonEventArgs e)
{
if (treeMenu.SelectedItem == e.Source) {
e.Handled = true;
packLaunch();
}
}
In fact this also doesn't work because after packLaunch(); a new window appears behind the main window, which is unacceptable.
Greetings - Gajatko
Portable.NET is part of DotGNU, a project to build a complete Free Software replacement for .NET - a system that truly belongs to the developers.
|
|
|
|
|
I want to know how to bind the data in the grid using listview control.
|
|
|
|
|
That's a fairly broad question, and not easily answered based on the level of detail in your statement (it's not really a question). Have a look at this[^] article and this[^] one.
|
|
|
|
|
Using silverlight, I need to display a world map. I should display the name of the country on keeping the mouse pointer over the country. Can anyone please help me? For example similar to this: http://whos.amung.us/maps/54u1eg18/textbook/default-orange
|
|
|
|
|
|
|
|
Good People,
I have created a custom listbox (via editing/creating my template for it). I do this via the build .dll option at start up in Expression Blend. When I use it in a project, if I resize it, everything flies apart or gets squished into each other (resizing larger or smaller respectively).
How do I make it stay together as one unit collectively so that upon resizing, it stays together?
Also, in my custom listbox, I added a listbox item and created a template for it. Alas, how do I access the custom listitem that I used the template to create? How do I bind data to it (from a CLR object)? For example, the custom list item has several labels and an image I need to change based upon what it's reading. Do I access it via procedural code (i.e. C#)? I tried, I found the custom control (i.e. this.CustomListBox), however I was unable to access any of it's content (i.e. title label and the list item box and its contents).
Thanks for any help or information you can provide.
BP
modified on Sunday, May 11, 2008 10:55 AM
|
|
|
|
|
To make sure that the resizing behaviour is correct, you should try resizing your template in blend and seeing how it behaves. Make sure that the columns and rows in the grid are setup correctly, and that the objects have the right column, row, columnspan, rowspans and margins. Double click the grid to enable row/column editing.
You can do the data binding in blend, in the project tab there are buttons to add a new data source. However I reccomend to check out the data binding documentation. As well as the articles here on code project.
Also you might want to post a bit more such as your DataTemplate the object it is for and the collection that is bound, if you have any more questions.
|
|
|
|
|
Hi,
I am creating a combo box, the database field is a binary with a true or false value.
I have to convert this and show "Lock" if the value is "true" and Unlock if the value is "False".
How do I do it with the databinding,
To begin with, I created an array,
private string[] binaryOnOffText = new string[2] { "Lock", "UnLock" };
public string[] BinaryOnOffText
{
get
{
return this.binaryOnOffText;
}
set
{
this.binaryOnOffText = value;
OnPropertyChanged("BinaryOnOffText");
}
}
And in my xaml I have used the booleantoIndexConverter,
<ComboBox ItemsSource="{Binding Path=BinaryOnOffText}" SelectedIndex="{Binding Path=OpenOnExitReq, Converter={StaticResource booleanToIndexConverter}}" >
</ComboBox>
public class BooleanToIndexConverter : IValueConverter
{
#region IValueConverter Members
public object Convert(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
bool boolValue = System.Convert.ToBoolean(value, CultureInfo.InvariantCulture);
if (boolValue)
return (int)1;
return (int)0;
}
public object ConvertBack(object value, Type targetType, object parameter, System.Globalization.CultureInfo culture)
{
return null;
}
#endregion
}
The binding does not work when I create the dialog(when I get the selection on the Lock irrespective of whatever value is saved), it work otherwise.
Am I missing something?
Thanks In Advance
|
|
|
|
|
Comboboxes has two sets of bindings.
One to get the data into the combobox.
The other to bind the SelectedValue of the combobox.
You need to databind the SelectValue property. Read up on this property and it will all fall into place.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
How do i read up on this selectedvalue property?
|
|
|
|
|
Google: wpf combobox selectedvalue
MSDN Documentation
Visual Studio Dynamic Help
modified 27-Feb-21 21:01pm.
|
|
|
|
|
For some reason I can't watch Silverlight dnrTV presentations anymore.
http://www.dnrtv.com/[^]
I upgraded to Windows Media Player 11 last night and I suspect it may be the culprit. Strange thing is that I use WMP 11 at work and dnrTV runs OK there. Tried uninstalling/reinstalling Silverlight, to no avail. Says "Unable to load media 'dnrTV_0110.wmv'." Happens in both IE and Firefox (in IE it just hangs).
I do have some downloaded wmv files on my PC and they run OK in WMP. Channel 9 is Silverlight and that is OK. ??? Has anyone else experienced this?
Both home and work PCs are XP Pro SP2. I'm using Silverlight 1.0.
Kevin
|
|
|
|
|
Are you behind the proxy? I used to get this error when I was behind the firewall... because Firewall may block the file..
I dont have Silverlight 1.0. but I have Silvelight 2 beta1. I have checked the video and it's working fine in my machine..
|
|
|
|
|
Hi Karl,
I've just been reading this article on CP:
http://www.codeproject.com/KB/WPF/WPFMasterPageControl.aspx[^]
Did you make any headway on your amendments to Karin's initial idea? Seems like a neat solution and its something I want to implement but seems problematic at the moment in terms of these potential binding issues.
Thanks,
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Jammer,
Never got any responses at all.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Hi All,
I have a 'normal' WPF application that I've working on in Blend and VS. The problem I'm having is when debugging with break points.
When a breakpoint is hit I can't then tab away from the app i'm debugging in order to step through the code in VS ...
Any ideas?
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
You're starting the application in Visual Studio right??
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Absolutely ... with an F5 ...
Jammer
Going where everyone here has gone before!
My Blog
|
|
|
|
|
Jammer,
What does tab away mean?
Are you referring to ALT-TAB?
Can you switch to Visual Studio using the task bar?
modified 27-Feb-21 21:01pm.
|
|
|
|