wpf

How can I determine which mouse button raised the click event in WPF?

I have a button that I trigger OnClick whenever there is a click on that button. I would like to know which Mouse button clicked on that button? When I use the Mouse.LeftButton or Mouse.RightButton, both tell me "realsed" which is their states after the click. I just want to know which one clicked on my button. If I change EventArgs ...

Problem imitating VS output window's textbox with a WPF TextBox

In Visual Studio's output window, you can position your text caret at the end of the output so that the textbox scrolls down automatically when new text is logged. And when the caret is not at the end, it won't scroll down. I would like to mimic this with a WPF TextBox. I was able to do it, but only if the TextBox is not read-only. That...

MVVM Inheritance With View Models

I am wondering about how to approach inheritance with View Models in the MVVM pattern. In my application I have a Data Model that resembles the following: class CustomObject { public string Title { get; set; } } class CustomItem : CustomObject { public string Description { get; set; } } class CustomProduct : CustomItem { ...

WPF WindowsFormsHost sizing

I wanted to wrap a windows forms control in a wpf UserControl <UserControl x:Class="MVVMLibrary.ReportViewer" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:ws="clr-namespace:Microsoft.Reporting.WinForms;assembly=Microsoft.ReportViewer.WinForms" ...

WPF TextBox Not Accepting Delete Key

Hello. I have a WPF application embedded in a Microsoft Outlook 2003 window. Everything is working fine, except none of my TextBox controls accept the backspace key. I've done some research, and the problem exists only when my window is a child of the outlook window and not if it's another window (I injected it into firefox and it wor...

Why does one of the paths not bind in this scenario?

Elements and FirstAttribute bind as I'd expect (if I didn't know it's a method), but Attributes does not, despite being a member of XElement, just like the others. I know about IValueConverter, and I'm using that to get the binding I want on attributes, but I'm curious as to why it works on Elements. <Window x:Class="WpfApplication6.Win...

XAML: How to define Data Templates & Styles to be used over several Projects

I'm starting to develop a Desktop application using WPF (.net 3.5 sp1, with VS only, not blend as yet). I'm at the point were I have some generic reusable components in several libraries. Where can I define my Styles & Data Templates so that they are reusable across several projects, so I can have a consistent look and feel? I've look...

How do I hook in to a double-press of the Ctrl key?

What I'm looking for is functionality similar to Google desktop. When you hit Ctrl twice rapidly, a little search box pops up. I've tried using a fairly heavy keyboard hook class that I found somewhere, but that kept giving meunpredictable results (ie first time it would work, then I'd press Ctrl once, and it would raise the key presse...

Binding a Popup to another controls relative screen position

I'm writing an XBAP w/a complex popup(canvas zindex of 99 w/a grid on it...) that I would like to "attach" to the button that opens it and follow that button around wherever it goes on the screen. For example if the button is in a ListBox or a XamDataGrid I would like the popup to follow the button as it scrolls through. If it is benea...

WPF: How to bind to a nested property?

I can bind to a property, but not a property within another property. Why not? e.g. <Window DataContext="{Binding RelativeSource={RelativeSource Self}}"...> ... <!--Doesn't work--> <TextBox Text="{Binding Path=ParentProperty.ChildProperty,Mode=TwoWay}" Width="30"/> (Note: I'm not trying to do master-details or an...

Why does Path=SelectedItem.Content work for ComboBox in WPF but not Silverlight?

The following code works fine in WPF. In Silverlight it gives me the error **Invalid attribute value {Binding ElementName=WhichNumber, Path=SelectedItem.Content} for property Text. ** How can I get this to work in Silverlight? <ComboBox x:Name="WhichNumber" Width="100" HorizontalAlignment="Left" Margin="10" SelectedIndex="0"> ...

Why does WPF databinding swallow exceptions?

I recently wasted a lot of time trying to debug a WPF datagrid (from the WPF Toolkit). I had a column bound to a linq query with a property that was throwing an exception (in a few rows). WPF seems to catch the exception and it just makes the cells blank. I have fixed the bug causing the exception, but I would like to change WPF's behavi...

Bizar WPF error - ITfKeystrokeMgr.TestKeyUp

UPDATE: I've build a WPF app with no code behind, just put in a TextBox and a button and built it. When running this application I can see the same error in this user's machine. You can click on the button, and it works ok, but as soon as you press a key on the keyboard the application throws the same error. Should I reinstall the .Net F...

MVVM: CollectionView in ViewModel or CollectionViewSource in xaml?

I'm developing a WPF application using the MVVM pattern and I need to display a list of items in a ListView (with filtering), with the fields of the selected item displayed in a Master/Detail view. I'm torn between the following two ways of doing this: Exposing a CollectionView in my ViewModel, and binding to this. Exposing a plain ILi...

IE7-like Quick tab with WPF

Hello all, I'm trying to create a IE7-like Quick tab (the tab that displays a thumbnail image of all opended tab) using WPF. How can I render the content of the tab items into images? Thanks, Shahaf. ...

How to convert image to text and text to image in wpf + c#

I want to develop an appication which can converts image to text format(some Ascii format) and text to image format. I want this because i need to decrease the size of the image file. Any suggestion plz. Thanks in advance, Ibrahim. ...

WPF Listview SORT and FILTER performance issue

Hi all , I have listview with custom sort and filter implemented on it...It is textbox based filter , as user types in, items in the listview are filtered. Now...when i apply sort on listview, filter is very slow because each time custom sort compare method is called for each item in listview while filtering... how I can avoid compa...

Set background color of WPF Textbox in C# code

How can I change the background and foreground colors of a WPF Textbox programatically in c#? ...

Problem referencing classes in external assembly in WPF designer in VS 2008?

Here, Data refers to a another class-library project in the same solution. The main project is referencing Data properly and there is a data.dll in the debug directory of the main project. Yes, I am able to build and run this solution properly. Is this a known problem? I searched on the web, but am unable to find a definite answer. ...

Adjust a Control Template and still respect the Theme of the OS?

In WPF how do I modifiy the template for a standard control in a way that it will respect the current Theme of the Operating System later on? If I just "edit a copy" of the template in blend, it will just give me the template of the currently running theme. Is this correct? So when I apply the modified template and run the app on differe...