treeviewitem

How to Subclass WPF's TreeViewItem and use it in a treevview

心已入冬 提交于 2019-12-23 17:21:44
问题 I have created a simple dependency property that I want to attach to a treeViewitem, I have done similar things for other controls such as buttons but cannot figure out how to use the TreeViewItem in a treeview without loosing my defined style. With the code below I get "A style intended for type 'ErrorTreeViewItem' cannot be applied to type 'TreeViewItem'." public class ErrorTreeViewItem : TreeViewItem { static ErrorTreeViewItem() { } public bool ErrorState { get { return (bool)GetValue

Make drawstring partially bold

无人久伴 提交于 2019-12-23 16:45:05
问题 Good morning. I have created a custom treeview control that paints a normal treeview onto the screen, plus various other things. During the paint event I draw the node.text string to the treeview control using the following method. node.text = "ABCDEFG" g.DrawString(node.Text, tvFont, Brushes.Black, strPosX + 10, bothPosY) Basically what I am trying to do is make part of the node.text italic, so that it renders on screen like so... AB*CDE*FG Personally I would approach this in such a way that

Why is the TreeViewItem's MouseDoubleClick event being raised multiple times per double click?

◇◆丶佛笑我妖孽 提交于 2019-12-20 10:17:05
问题 XAML <TreeView Name="GroupView" ItemsSource="{Binding Documents}"> <TreeView.ItemContainerStyle> <Style TargetType="{x:Type TreeViewItem}"> <EventSetter Event="MouseDoubleClick" Handler="OnTreeNodeDoubleClick"/> </Style> </TreeView.ItemContainerStyle> .... </TreeView> Code-Behind private void OnTreeNodeDoubleClick(object sender, MouseButtonEventArgs mouseEvtArgs) { Console.WriteLine("{3} MouseDoubleClick Clicks={0} ChangedButton={1} Source={2} Handled={4} ButtonState={5}", mouseEvtArgs

wpf manually generate TreeViewItem container

北城余情 提交于 2019-12-20 03:19:50
问题 I am creating a TreeView at runtime. It has several nodes(TreeViewItem), each one having a name. Initially it is collapsed. A separate comboBox displays Names of all TreeViewItem. I have to highlight a TreeViewItem based on the Name selected. I am using a recursive function and gets the TreeViewItem container like this: if (parent.ItemContainerGenerator.Status != GeneratorStatus.ContainersGenerated) continue; TreeViewItem container = parent.ItemContainerGenerator.ContainerFromItem(child).As

javafx how to disable one item in checkboxTreeItem?

只谈情不闲聊 提交于 2019-12-19 11:28:31
问题 I am new to JavaFX and I am having a problem in checkbox Tree View. I want to disable one item inside root value ** Serial No but as per JavaFX documentation, it seems that it is not possible. I have disabled click effect cbTreeViewdisable(treeItems, 3) Is there any way to grey out any one value (or set an id) so that user knows it is disabled. private TreeView<String> cbTreeView; @Override public void start(Stage primaryStage) { StackPane root = new StackPane(); cbTreeView = new TreeView();

KeyBinding on a TreeViewItem

落花浮王杯 提交于 2019-12-19 06:08:04
问题 I have a typical treeview and a viewmodel. The viewmodel has an observable collection of other viewmodels that serves as a data source for the tree. public class TreeViewVM { public ObservableCollection<ItemVM> Items { get; private set; } public ItemVM SelectedItem { get; set; } } and the ItemVM : public class ItemVM { public string Name { get; set; } public ImageSource Image { get; private set; } public ObservableCollection<ItemVM> Children { get; private set; } public ICommand Rename { get;

In WPF, how do I select the treeview item under my cursor on right-click?

爷,独闯天下 提交于 2019-12-19 05:16:20
问题 In WPF, when I right-click on a treeview item I would like it to be Selected/Activated before showing the context menu. This sounds pretty simple, but the inclusion of a hierachicalDataTemplate complicates things a little. I have the following treeview: <TreeView x:Name="trv" ContextMenu="{StaticResource contextMenu}" ItemTemplate="{StaticResource treeHierarchicalDataTemplate}" ItemsSource="{Binding Source={StaticResource meetingItems}}" > <TreeView.ItemContainerStyle> <Style TargetType="{x

Apply style to all TreeViewItem

こ雲淡風輕ζ 提交于 2019-12-18 16:58:31
问题 Hi The problem am having is that I have multiple TreeView control and each TreeView has its own TreeViewItem styles, setting it TreeView ItemContainerStyle="{StaticResource Style1}" will only set the root element NOT all the child elements, How to apply a style to all the child elements in a TreeView 回答1: There are several ways to accomplish this: You could make your style the default for all TreeViewItems: <Style TargetType="{x:Type TreeViewItem}"> ... </Style> The difference is that you do

pass contextmenu parent as CommandParameter

戏子无情 提交于 2019-12-18 09:45:56
问题 i have a HierarchicalDataTemplate for a TreeViewItem, in the template i have a contextmenu and i want to pass as CommandParameter the ContextMenu parent - i.e the TreeViewItem owner that was right clicked at the moment, is there a way to do that? here is my template: <HierarchicalDataTemplate x:Key="ServerTemplate" DataType="{x:Type models:Server}" ItemsSource="{Binding Channels}" ItemTemplate="{StaticResource ChannelTemplate}"> <StackPanel Tag="{Binding DataContext,RelativeSource=

Invoke Command when TreeViewItem is Expanded

我的未来我决定 提交于 2019-12-18 05:03:19
问题 Sounds simple enough? I have a TreeView, and I want something to happen when one of the nodes is expanded. I'm using MVVM, so that 'something' is a command in the ViewModel. Well, I'm finding that it's not so simple after all. I've looked around and tried a few things. For example, using MVVM Light's EventToCommand: <i:Interaction.Triggers> <i:EventTrigger EventName="TreeViewItem.Expanded"> <cmd:EventToCommand Command="{Binding Path=FolderNodeToggledCommand}" /> </i:EventTrigger> </i