wpf

How can I tell if a drag and drop operation failed?

It seems to me there is no way to detect whether a drag operation was successful or not, but there must be some way. Suppose that I want to perform a "move" from the source to the destination. If the user releases the mouse over some app or control that cannot accept the drop, how can I tell? For that matter, how can I tell when the dra...

Two way data binding in a GridView

We have an app that uses simple one way binding with a GridView to display some data. Well, now we need to allow the user to change some of that data, so I've been trying to get two way data binding to work in the GridView. So far everything displays correctly, but editing cells in the GridView seems to do nothing at all. What am I messi...

Is there a good way to display a DataTable in pure WPF?

Is there a good way to display a DataTable in pure WPF? I'm looking for something similar to System.Windows.Forms.DataGrid, but only for one data table, and in WPF. ...

Built-in WPF IValueConverters

Ok, it was a nice surprise (after writing it several times) to find that there already is a BooleanToVisibilityConverter in System.Windows.Controls namespace. Probably there are more such hidden time-savers. Anyone got some? ...

How do I get System.Windows.ShowDialog() to return 'true'?

How do I get System.Windows.ShowDialog() to return 'true'? I am a little new to this. System.Windows.ShowDialog's return type is bool? It is supposed to return true when you hit Submit, and false when you hit Cancel. But I am not sure how to designate which button is the official submit button. EDIT: On a related note, I am curiou...

WPF Binding vs Event Handling

I'm new to WPF and come from a WinForms background and have a fairly basic question about binding vs event handling. To try and maintain some separation of responsibility I've have a bunch of presentation objects which simply have dependency properties to hold the UI data parts of a business object, the business object contains similar...

hide the default resize grip in wpf

I have a borderless and transparent window in WPF, with some fancy decoration at the bottom. There's a custom footer with some non conventional curves and what not showing the company logo. This window needs to be resizable with a grip in the bottom right corner like conventional windows. Anyways, I have put my own ResizeGrip in a place...

WPF scrollbar should change value more frequently

I currently tried to force a wpf scrollbar to fire it's value changes for often, if the user presses the scroll-up or -down button, and holds the mouse button. I tried to use a style like: <Style TargetType="{x:Type RepeatButton}"> <Setter Property="Interval" Value="20"/> <Setter Property="Delay" Value="20"/> </Style> Or to s...

free WPF application templates?

Are there sites which have free "WPF Application templates" such as freecsstemplates.com has for HTML sites? I'm looking for something that has a nice-looking layout, functional menu, etc. in XAML that you can build on. ADDENDUM Although themes are nice, I'm also looking for a layout, something like the layout I created with a silverl...

How to properly bind a ListBoxItem in WPF ?

I have a listbox and I want to iterate over a collection of Bars in my Foo-object. <ListBox DataContext="{Binding Path=Foo.Bars}" > <ListBox.Items> <ListBoxItem> <ContentControl DataContext="{Binding Path=.}" /> </ListBoxItem> </ListBox.Items> </ListBox> This is the datatemplate I want to use. <Dat...

Set TextBlock to be entirely bold when DataBound in WPF

I have a databound TextBlock control (which is being used inside a DataTemplate to display items in a ListBox) and I want to make all the text in the control bold. I can't seem to find a property in the properties explorer to set the whole text to bold, and all I can find online is the use of the <Bold> tag inside the TextBlock, but I ca...

Findresource throws exception - WPF/C#

I am writing a CustomControl in WPF. I have some DataTemplates in my Themes/Generic.xaml, at the resourcedictionary level, with x:Key assigned for them. Now from within the same control class code, i want to find and load that resource so i can dynamically assing to something in the code. I have tried base/this.FindResource("keyvalue")...

Blurred/Pixellated display of DataTemplate for ComboBox in WPF

I have a DataTemplate giving items for display in both a ListBox and a ComboBox. The window I have created looks like this: The question I have is why the DataTemplate in the ComboBox is blurrier or slightly more pixellated than the display in the ListBox. It is quite difficult to see on the screenshot, but it seems more noticeable whe...

What is the issue with UserControls in XAML / WPF?

I have had major problems with getting UserControls to work in XAML - I have spent hours trying to figure out all the problems but have got nowhere and cannot find where I am going wrong. The main problem I am having is when I create a UserControl for example a simple one which shows an object different colours - I have successfully crea...

WPF: Invalidate controls in ControlTemplate

I've created a decorator which draws some custom graphics in OnRender method. The graphics depend on the position of the object containing the decorator. I set the decorator via Template property through Style. The problem is that the OnRender method of the decorator is called only once when the template is applied. So when I change the ...

How do I format headers on a WPF Datagrid?

I am using the WPF Datagrid from Codeplex. I am able to style the rows and with the following attributes in the dg:DataGrid element. But how do I style the Headers? I find 100s of examples on the web which define Styles and use e.g. x:Key="DataGridColumnHeaderStyle" in the Datagrid element, but none of them seem to work for me. How ca...

How do I maintain coherency between model and view-model in MVVM pattern?

Problem Statement I'm writing a very basic WPF application to alter the contents of a configuration file. The data format is an XML file with a schema. I want to use it as a learning project for MVVM, so I have duly divided the code into Model: C# classes auto-generated from xsd.exe View-Model: View-friendly representation of the ...

How to allow the user to add annotations to UI controls in WPF?

WPF document viewing controls that support annotations include FlowDocumentReader and FlowDocumentScrollViewer, as well as controls derived from DocumentViewerBase such as DocumentViewer and FlowDocumentPageViewer. The in-built Annotations support for Document based controls is awesome in WPF I was wondering how would it be possible to...

ItemActivated event in WPF ListBox or ComboBox

Is there an ItemActivated event (like in Windows Forms) in the WPF ListBox or ComboBox controls? I can't see one. It seems crazy for there not to be some event doing the same kind of thing - so does it just go by another name? If not, is there another easy way to do it? I've seen various blog posts about this but they all seem to involv...

How to read a passed parameter in a WPF UserControl?

I created a user control in WPF: <UserControl x:Class="TestUserControl.Controls.GetLatest" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; <TextBlock Name="theTextBlock"/> </UserControl> The code behind has a parameter called "FirstMessage" wh...