wpf

Bind StackPanel.Visibility to the Visibility property of its children

I'm relatively new to DataBinding and just reading into it. What I want to do is the following: I have a StackPanel with a number of child controls: <StackPanel Orientation="Horizontal"> <TextBox x:Name="textbox1" Width="100">1</TextBox> <TextBox x:Name="textbox2" Width="100">2</TextBox> <Tex...

Identifying a button in a templated ListBox.

I have a ListBox that has a custom DataTemplate assigned to it, so that it can correctly display it's content - a custom "Accessory" (which consists of three string properties) object per row. Additionally, there is a button on each row. That button should trigger an event that adds the selected accessory to a MemoryList. Here is the Dat...

Dynamic loading of images in WPF

I have a strange issue with WPF, I was loading images from the disk at runtime and adding them to a StackView container. However, the images were not displayed. After some debugging I found the trick, but it really doesn't make any sense. I've made a small demo app to identify the problem: Create a new WPF project, and paste code as ...

Where is the best place to store global information in a WPF application?

I'm a former PHP developer now doing WPF/C# applications, and am having trouble understanding the best way to access global variables and how UserControls access the main Window, etc. In the constructor of my Window1 class I load UserControls into an internal Dictionary, then dynamically load these into a DockPanel at runtime, which wor...

WPF DataBinding - Fire event from a repeated control button

Following from my question on binding in general, I'd like to ask for help on the following scenario. I have a collection of objects (imageFileData) displayed via a DataTemplate in a ListBox control. The control is bound to an ObservableCollection. Both the collection and the template are defined within my application xaml and xaml.cs...

Focus DataTemplate in WPF

The behaviour I am looking for is that a selection of a Item in a ListView results in focusing the first focusable visualchild. Problem: datatemplated data in a ItemsControler which does not get an initial focus. In the example below there are 4 Strings which are then stuffed into a TextBox via Datatemplate. Example: <Window xmlns="ht...

Binding FrameworkElementFactory to data object property

I have a ListBox whose DataTemplate is created in code using 3 FrameworkElementFactory objects(A StackPanel with 2 appended children(CheckBox and TextBox)). The item object in the collection that is bound to the ItemsSource of the ListBox is basically the same type of Item object that you would typically see with any type of ListControl....

Manually create unbound datagrid

Can anyone tell me if it is possible to create and add data to an unbound WPF Toolkit datagrid. If it is in fact possible to do, can someone please provide an example of the following: Programmatically: create a datagrid create a datagridtextcolumn add the datagridtextcolumn to the datagrid create a datagridrow set the text of the data...

INotifyPropertyChanged vs. DependencyProperty

I need to watch properties for changes. Which method is better in terms of performance and memory use: implementing INotifyPropertyChanged or using a DependencyProperty? Note: Yes, I have read the other question INotifyPropertyChanged vs. DependencyProperty in ViewModel. ...

WPF listview / gridview performance horrible, suggestions

I have a window using a WPF ListView/GridView bound to an ObservableCollection. The performance is utterly horrific. The application chokes trying to load 300-400 items and CPU usage spikes each time an item is added/removed/modified. Profiling doesn't reveal anything obvious. Anyone have any suggestions? ...

WPF: Loading data in the constructor of a UserControl breaks the Designer

I have a main window with a usercontrol. When adding code in the default constructor of the usercontrol, the designer stops showing the main window. It gives a message: Problem loading The document contains errors that must be fixed before the designer can be loaded. Reload the designer after you have fixed the errors. ...

Does WPF databinding make things more of a pain than it is worth?

Ok, So I have been stalled in my latest non-work project, trying to use WPF. I am just frankly annoyed at databinding. I thought it was supposed to make things simpler by binding data directly to the UI. But the more I learn about having to implement INotifyPropertyChanged to get things to notify the UI if they changed, seems to make...

WPF: How to implement Drag and Drop with nested (hierarchical) controls

Using WPF I've succeeded at implementing drag and drop to rearrange items within a list(view or box) and also to drag and drop items between lists. Now I am trying figure out how to implement drag and drop with NESTED lists. For instance I have a listview containing projects and each project item contains another listview of tasks. I ...

Writing video frames with variable framerate

I'm using the AVIFile Wrapper to create video from my WPF app. I'm using CompositionTarget to grab an image for each frame but I'm having problems with framerate. As my app slows down with heavy data load, the CompositionTarget frame rate drops. With less video frames, when I play back these parts appear as fast forward. Is there a vide...

WPF: Datatemplate For Class

I have this XAML: <UserControl x:Class="M_Cubed.Controls.TagEditor" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:classes="clr-namespace:M_Cubed.Classes"> <UserControl.Resources> <DataTemplate DataType="{x:Type classes:TagEditorPic}"...

WPF Dependency Property question ... need advice on what to do in this particular scenario:

I am attempting to create a sukodu (like crossword) player in WPF, and I realize that I have a whole bunch of controls that will need to know the sudoku grid to function. Because of this, I think the Sudoku Grid object would be a good candidate to create a dependency property. I am about to start the work, but I have some lingering ques...

Does the book Programming WPF has insufficient XAML coverage?

I am about to buy Programming WPF, but am undecided after reading this. Can anyone who has read this book tell me if it has insufficient XAML coverage. In fact one of the reviewers at Amazon mentioned that the following topics are not covered. dynamic data binding how to create an app start to finish using expression and all of the ...

DatePicker with the ability to choose a span.

Here is a quick visual of the idea that I got from Google Analytics. ComboBox Collapsed: ComboBox Expanded: I am not concerned with the functionality of the timeline or the date range text boxes. Basically I am looking to have something that looks kind of like a ComboBox with a single calendar control. When the date range is selec...

RemoveAt in Observable Collection, also modifies IsSelected Property in ListView

Hi I would try as much explicit as I can. I have two UI objects, this is a TabControl and a ListView, both are binded again two different list of the same objects, both have the IsSelected property binded against the Item.IsSelected as the View Model Commands, this works perfectly, (I can prove it, by selecting in one of the source...

How to find a ListView in a DataTemplate?

I have this ListView in xaml <ListView x:Name="PersonsListView" ItemsSource="{Binding}" ItemTemplate="{DynamicResource personLayout}"> <ListView.Resources> <DataTemplate x:Key="personLayout" DataType="Person"> <StackPanel Orientation="Vertical"> <TextBlock Text="{Binding Path=FullName}"/> ...