wpf

WPF: Detect when selected item changes

I have a control that is data-bound to a list box. All of the bound properties are being updated correctly. However, the control needs to know when the selected item changes so that it can do some other cleanup. Is there an event that covers this? ...

WPF: Change background color for selected ListBox item

This is my XAML so far. <ScrollViewer Grid.Column="1" Grid.RowSpan="2"> <ListBox Background="Black" ItemsSource="{Binding Path=ActiveLog}" > <ListBox.ItemTemplate> <DataTemplate> <Grid Background="Black"> <Grid.ColumnDefinitions> ...

Dynamic data-entry forms in Silverlight.

We are investigating how to create data entry views from a dynamic list of pre-defined field definitions. By "pre-defined", I mean that there are only 8 basic field types. The Silverlight Toolkit's DataForm control is almost what want, but it targets object properties (not a list of custom definitions). Is there an existing project to...

WPF TreeView bound to ObservableCollection not updating root nodes

Sorry - my question is almost identical to this one but since it didn't receive a viable answer, I am hoping that someone else has some fresh ideas. I have a WPF TreeView that is bound to a hierarchy of a single type: public class Entity { public string Title { get; set; } public ObservableCollection<Entity> Children { get; set...

How to Get the number of the displayed row in wpf datagrid

Hi: For winform datagridview , we can use "DisplayedRowCount" to get the number of the displayed row, How can i get it for wpf datagrid. Thank you~~ Rui ...

WPF Custom Items Control with search support

Hi ! I need to write a custom WPF control that should look like a ComboBox with extended items search feature. For this purpose I'd like to have a TextBox and a Popup with a search TextBox and a ListBox. My first question is if it's a good decision to inherit from Selector, or rather ComboBox ? The second question is where can I find...

How to keep collections of viewmodels and models in sync

Hi, I'm using the wpf toolkit datagrid to display an observable collection of AccountViewModels. The thing is when I delete an account from the grid, I want it removed from the ObservableCollection - to give the user visual feedback, but i want the underlying list of Account models to remain the same, just with an 'IsDeleted' flag set ...

How to handle exceptions thrown during the instantiation of a WPF Application?

I'm using the following code to display unhandled exceptions in a WPF application: public MyApplication() { this.DispatcherUnhandledException += (o, e) => { var exceptionMessage = new ExceptionWindow(); exceptionMessage.ExceptionMessage.Text = e.Exception.Message; exce...

WPF event routing

I have a grid control which has two child elements (both are canvas), and first canvas overlays the second one. How can I handle mouse down event on background canvas? ...

ICommand Implementation Question

I am doing the following tutorial, to learn about the MVVM pattern in WPF. There's something I don't understand about the following seemingly partly given implementation of ICommand interface. In the code below the _canExecute variable is used as a method and a variable. I was thinking it's some event of some kind, but ICommand alrea...

Populating columns of a window

What I am trying to do is populate two columns in a window. This columns will have the name of the global variable and the path it to it. I am having problems displaying what i need in the windows. <TabItem Header="Global Variables" GotFocus="GlobalVariablesTab_GotFocus"> <dc:TreeListView Name="tvwGlobalVariables" ...

How to put a MouseDown event in a Style?

This works: XAML: <Window x:Class="Test239992.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="300" Width="300"> <StackPanel> <TextBlock Tag="1" Text="Customers" MouseDown="Handle_Click"/> <TextBlock ...

ListBox instead of ItemsPresenter in WPF Custom Control ?

Hi ! I'm writing a generic control template for my WPF Custom Control. But with ItemsPresenter I only got raw list of Data.. Compared to the ListBox, the ListBox has all features I need. Is it wrong to use a ListBox instead of ItemsPresenter ? What I'm after is that if I write a generic Template that uses a ListBox and in code behi...

WPF Highlight Item

I have a ViewModel that provides a collection of Items. There is also a ActiveItem propery. The Items collection may or may not contain ActiveItem. What I want to do (in XAML) is display the items as a list and highlight any of the items that are equal to Active Item. I have tried the following with no success: <ListBox ItemsSource="{...

How to Develop a Public API Object Model In a WPF Desktop Application That Allows For Out-Of-Process Automation From Another .NET Desktop Application

We're developing a large desktop application using Windows Presentation Foundation. Currently, the application is for internal use but will eventually be sold as a commercial product. I'm currently using a variation of the M-V-VM design pattern to keep as much code out of the UI components (i.e. windows, user controls). I know at some po...

Any way to reuse Bindings in WPF?

I'm getting to the point in a WPF application where all of the bindings on my controls are getting quite repetitive and also a little too verbose. Also if I want to change this binding I would have to change it in various places instead of just one. Is there any way to write the source part of the binding once such as in a resource and...

What's wrong using self defined enums versus system enums when binding wpf data

Hello everybody, I was trying follow almost all tutorials regarding wpf data binding, I stil have problem to bind a comboBox with enum property which defined by me in a different namespace. The enum: namespace H3S.Interopability { public enum eDataBits { DataBits5 = 5, DataBits6 = 6, DataBits7 = 7, D...

Edit CSS in WPF Webbrowser control

I want to build a lightweight (wysiwyg) css editor based on the WPF webbrowser control, so I need to be able to manipulate the css. I figure you can get the HtmlDOM from the Webbrowser.Document property, however i'm having some difficulty figuring out how to obtain and edit the document's css. ...

WPF DataTrigger not firing when Application style applied???

Hi guys, Any help on this problem would be greatly appreciated as I have been looking around all day for answers surrounding this area! I have applied a global style to my WPF application by adding in a merged dictionary to the App.xaml. This has applied the style across the application like intended but there are a number of things t...

WPF ICollectionView Filtering

Hi ! I've written a code for filtering items in ComboBox: My question is, how would you do that? I think that this solution with reflection could be very slow.. ICollectionView view = CollectionViewSource.GetDefaultView(newValue); view.Filter += this.FilterPredicate; private bool FilterPredicate(object value) { if (...