wpf

Change in a thread safe observable list generates an exception on index bounds

I am trying to make a change in an observable list bound to a wpf control from a background thread. I used for that a class that inherits from IList and INotifyCollectionChanged and all access to the collection are controled with a ReaderWriterLock. However, when I try to add an element to the collection an exception is raised: Notif...

Filter itemssource of one control with the selected value of another control in WPF

I have a combobox and a listbox in a WPF window. The combobox's itemssource is set to a List of all Team objects. Team has 2 properties (TeamId and TeamName). The listbox's itemssource is set to a List of all Player objects. Player on of Players properties is TeamId. I would like to filter the list of Players in the Listbox to only sh...

WPF Datagrid group expander text - how to bind ??

I am using a datagrid with a combox that should change the grouping field. I am using the following xaml to define the general grouping template : <DataGrid.GroupStyle> <GroupStyle> <GroupStyle.ContainerStyle> <Style TargetType="{x:Type GroupItem}"> <Setter Property="Template"> ...

DependencyProperty.Register() usage?

Hi, I have 2 controls A and B that need to share a dependency property. A has the property defined as: public static readonly DependencyProperty PathProperty= DependencyProperty.Register("PathProperty", typeof(string), typeof(A), new PropertyMetadata(string.Empty, OnPathChanged)); public string Path { get {...

WPF, XML databinding into dependent/cascading ComboBoxes

I have an XML file with the following structure: <Products> <Product name="MyProduct1"> <Components> <Component name="MyComponent1"> <SubComponents> <SubComponent name="MySubComponent1"/> <SubComponent name="MySubComponent2"/> ...more SubComponent nodes... </SubComponents> ...

How to create List-like UserControl in WPF?

I want to create my own expandable/collapsable tree-like UserControl, which nodes are the Border elements with any content. And this control should have the single SelectedItem. When I select one of the nodes I want to see details information about selected item. I've done the control's presentation and a piece of logic: I can see all t...

Improve WPF Application Coldstart: Suggestions to run program when machine starts up.

Is it possible to load your WPF application when the machine starts up? Our WPF application is taking 30 seconds on our existing client hardware, and we'd like to "hide" that by having our application startup when the machine is booted. But the fact that our application boots on startup should be invisible to the user. How would we go...

WPF - Updating Label Content During Processing

Hey all Well I've tried several methods of getting this to work, background worker, Dispatcher.Invoke, threading within the called class and nothing seems, to work. The best solution so far is an Extension method which calls the invoke of the control. Also I've tried avoid passing the data for the label through my event classes and simp...

extend a control

Hi In regular C#, if i want to extend my class, i inherit from the base one and add my class. I have a XAML UserControl, i want to add a new functionnality. For instance, i have a DataGrid, and i want to add a Contextmenu that allows to user to print. I don't quite see how should i inherit from the the usercontrol ? thanks Jon ...

Can controls rendered within a wpf Viewport3D using a VisualBrush fire their specific events?

Hi, I'm trying to render a Button on a GeometryModel3D by using a VisualBrush. Is there a way I can handle the button's click event directly? (or is it that the VisualBrush only renders the image of a button and I am supposed to use the VisualTree in order to check if the button was pressed? ) Thanks! ...

WPF, using XPath in XAML with XmlDataProvider to select nodes based on selected value in ComboBox

This question ties to my previous question but is more specific. Say I have two ComboBoxes, one populated with product names, the other empty. When a product is chosen, I want the second ComboBox to be filled with data related to that product. I have XML like the following: <Products> <Product name="MyProduct1"> <Componen...

WPF Listview: Aranging the Headers vertically

So i think this is quite an easy thing, but i really don't know how to get it done. I Want a Listview instead of this: Name|Age|Sex Bob|30|Male being aranged like this: Name|Bob Age|30 Sex|Male I hope someone can help me :) ...

Using WPF StoryBoard Forward and Reverse

I need help in the Storyboard Seek. The following code is not working: Storyboard StoryBoard; public void Reverse() { StoryBoard.Pause(this); TimeSpan ts = new TimeSpan(0); ts.Subtract(TimeSpan.FromMilliseconds(1000)); StoryBoard.Seek(this, ts, TimeSeekOrigin....

How do you scroll a xaml grid when viewable area is less than minHeight?

I tried placing a XAML Grid inside of a ScrollViewer, but the grid automatically resizes with the content. When I add 50 items to ListA, the vertical scroller shows up. If I set the VerticalScrollBarVisibility="Disabled" then the Grid displays as it should. What I'd really like is for the ScrollViewer to be disabled unless the width fall...

How to remove the default margin on the content of a TabItem?

I'm using the TabControl class in WPF and I've noticed that the content of each TabItem has a default margin of 4 pixels on all sides. Sample code: <Window x:Class="TabControlPadding.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Windo...

Can I get notified of changes to a DependencyProperty that I did not create?

I am using a 3rd party control that exposes a bunch of dependency properties (ex: SomeNumber) but do not supply corresponding changed events (ex: SomeNumberChanged). I would like to handle the event when the value changes. I know there is the OnPropertyChanged callback when you register the DP, but is there a way to hook into this when...

combining resources in xaml

I have a window that is composed of several UserControls, three of which are DataGrids. It looks like this: <DockPanel LastChildFill="True"> <local:MainRibbon DockPanel.Dock="Top" .../> <local:LeaveTimeActivityGrid ... /> <local:AdminActivityGrid ... /> <local:TotalsFooter ... /> <local:ProjectActivityGrid ... />...

WPF: Trouble controlling a button's enabled/disabled state using Command binding and a thread

I have a WPF app that simply contains a Button and a Textbox to display some output. When the user clicks the Button, a thread starts which disables the Button, prints stuff to the output Textbox, then the thread stops (at which point I want the Button to be enabled again). The application appears to disable the Button properly, as wel...

How can I display a grid of data using WPF?

To learn WPF, I am trying to create a hex editor application. However, I am unsure of what I should use to display the hex dump to the user. I am trying to display an array of integers in 16 columns. The first byte would be in column 1, row 1, the second byte in column 2, row 1, and so on. I had considered using an array of TextBlock, ...

Set SelectedItem of WPF ComboBox

<ComboBox Grid.Row="1" Grid.Column="0" Width="Auto" Margin="4,0,8,0" VerticalAlignment="Top" Name="cmbBudgetYear"> <ComboBoxItem Content="2009" /> <ComboBoxItem Content="2010" /> <ComboBoxItem Content="2011" /> <ComboBoxItem Content="2012" /> </ComboB...