wpf

WPF UserControl with generic code-behind

I have this code behind: CustomUserControl.xaml.cs namespace MyProject { public partial class CustomUserControl<T> : UserControl { ... } } and this xaml: CustomUserControl.xaml <UserControl x:Class="MyProject.CustomUserControl" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" x...

How to use DotNet EXE as OLE object

Hi, I would like to insert my DotNet EXE application in excel sheet just like an OLE object. Is it possible? If yes, how we can do this. In Excel 2003 when we click Insert->Object menu item, we get the 'Object' diloag. The 'Create New' tab of this dilaog contains varios OLE objects. I would like to display my DotNet exe application in ...

How to change focus from a textbox to another textbox with code in WPF - C#

I have Five textboxes as part of a grid. <TextBox Name="A1" MaxLength="1" ></TextBox> <TextBox Name="A2" MaxLength="1" ></TextBox> <TextBox Name="A3" MaxLength="1" ></TextBox> <TextBox Name="A4" MaxLength="1" ></TextBox> <TextBox Name="A5" MaxLength="1" ></TextBox> Initially cursor will be focused at A1 using the command A1.Focus(). A...

How to close a window in c#

I've got the following code in a window B that is started in its own thread from a window A. view.Closing += (sender, e) => { view.Visibility = Visibility.Collapsed; e.Cancel = true; }; When I close window A window B remains in memory and the application doesn't dispose. How should I go forward make sure that the application i...

bring to front (property) equivalent in wpf

I have a expander and textblock.... it at times overlaps for spaces.. i want the expander bringtofront.. but no such property in wpf.. how to do it? ...

DataContextChanged of a Tab in a TabControl is raised too early

I have a TabControl binding to some items. Underneath it is a Button where I can add items dynamically. On adding an item, the new item should become the active Tab (works fine with TabControl.SelectedItem): <Window x:Class="WpfApplication1.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xml...

Is it possible to add a default ComboBox entry with command binding in XAML?

I'm working on my first true WPF MVVM pattern application. Currently I have a number of ComboBoxes on various screens that are bound to Collection classes and properties of the relevant ViewModel class. They always have an entry with the text <Add>, which is really an empty object class and I currently use it to trigger an AddNewObject...

WPF: Hide ListBox groups when all contents are hidden

I am working on an application that has some ListBox's of information, it is possible that these could hold quite a lot of information (maybe up to 6 or 700 complex items - multiple text fields and images). I used the ListBox control in order to use the grouping, sorting and filtering functionality that you get with it, but it turns out...

howto create dynamic gridview in a listview item in wpf

Hi! This is the situation: I've got a listview with some item. Each of these item have got an other list, and I would like to show this list in a gridview. So I'd like to show the main listview with expanders, and if the user expand one of this item, it will show the other list in a gridview. The problem is that, the gridview must be...

ChangePropertyAction to modify Visibility not working in ListBoxItem DataTemplate.

I am trying to change the visibility of a control in a ListBoxItem template (based on it beeing selected in the parent listbox) through a ChangePropertyAction but the code below does not work. I tried fiddling around with setting the TargetName on the trigger or setting the default visibility of the control through a style. I debugged th...

Open a popup during mouseover of listbox textblock

Photosuru has a neat effect - when you mouseover the thumbnail image a popup opens showing the image enlarged. I am trying to get this to work on a listbox, similar to a tooltip, I need to mouseover an item and have the popup open. The problem, the popup only shows the item selected in the listbox. I tried looking through Photosuru code ...

Dynamically create elements and bind them to a List<T>

I have a ObservableCollection<Class1> where Class1 contains x and y positions as properties. The list can be of any size. I have a ViewModel that exposes the collection as a property. In my view, I want to generate a list of elements based on the collection and then set their x and y positions based on the Class1 Object's properties. Ho...

ListView scroll to last item WPF C#

how to make scroll rule always at end of the ListView automatic without focus in WPF? ...

How to Bind to a Child's Background in Xaml?

I'm able to bind to a child's Background if the child is explicitly named in ElementName: <TreeViewItem Header="Test" Background="{Binding ElementName=TestChild, Path=Background}"> <TextBox Name="TestChild" Text="Hello?" Background="{Binding SomeBinding}" /> </TreeViewItem> I'd prefer to use relative position rather than specific n...

Mimicking Validation Behaviour without Validation

We have several data objects in our application that wind up bound to grids. We have them implementing the IDataErrorInfo interface, so that by adding error messages to the properties, we see the rowheader change style and the DataGridCells gain a red border. All well and good. We now have an additional requirement that rather than...

DataServiceContext in WPF ViewModels

Hi, So I have a WPF application accessing entities through WCF Data Services. At the moment, I am accessing the proxy class that implements the DataServiceContext directly in my ViewModel. For example: this.context = new MyOwnDataServiceContext(new Uri("http://localhost/myowndataservice")); I then populate entities on the ViewModel f...

Large Model Collections in MVVM

Hi everyone, Whilst implementing my first MVVM application in WPF, I've been wondering about the pros and cons of wrapping Model collections in related ViewModel collections to use in the View. In our system we are likely to have several potentially large collections e.g. Order Lines in an Order, and Stock Items which could be selected...

Installshield error 1309.Error reading from file.

Hi. I have a Basic MSI Project. I have three discs I am going to span the content on for the release. I have three features I am using for this, each with their own individual content. I use the project assistant->Application Files tab to select each feature and add content to them. When I drop-down the "All Application Data: tab, I dr...

Application freezing while creating visual container for DataGrid rows

I'm currently working on a problem that has me on it's toes for the last weeks or so. This is not a normal freezing problem solveable by multi-threading, because I'm doing this already for the business logic. I have a View with a DataGrid, the DataContext is a ViewModel supplying an ObservableCollection<T> to a CollectionViewSource nam...

How do I make a XAML GridView display one of several images, depending on a DisplayMemberBinding?

Hi, I've got an Enum called "DoYouKnow", containing Yes, No and Unknown. I have a column in a GridView which currently displays "Yes", "No" or "Unknown" in each row, based on a DoYouKnow value I've attached it to using DisplayMemberBinding. Instead of displaying I would like to have this column display a tick, a cross or a question ma...