wpf

Add controls to empty cells in a Grid that's the ItemsPanelTemplate for a ListView

I have a WPF ListView, which has a Grid as an ItemsPanelTemplate. I display my items in the correct column and row based on a property of the item. But I would like to put some controls in the empty cells of my grid. This is a simplified version of my code and xaml: In the resources: <ItemsPanelTemplate x:Key="TheTemplate"> <Grid>...

Text highlighting inside a WPF toolkit DataGrid

I wanted to know if it is possible to highlight text inside a WPF toolkit datagrid. My aim is to mimic the ctrl+f find functionality of internet explorer inside a DataGrid. With each click of find, the next instance of the searched keyword should be highlighted. This is the best I have seen on the net. http://blogs.microsoft.co.il/blogs...

wpf overriding getHashCode and Eqaul in ContentControl

Hi I have a class which derives from ContentControl and I'm not able to override GetHashCode and Equal method. I get an error Error 5 cannot override inherited member 'System.Windows.DependencyObject.GetHashCode()' because it is sealed Is there any way to override this method ? I need to use Union method from LINQ however I need to c...

Binding to property on root element in DataTemplate through a ContentControl

In my user interface I sometimes want to put titles above usercontrols. I want to declare these titles in XAML for future localizability, so I want to keep them out of the datacontexts. Can databinding fetch them from a property set on the root node of the usercontrol? I have boiled the problem down to the following code example: usi...

WPF DatePicker default to today's date

WPF DatePicker always show 'Show Calendar' by default. I want it to show current/todays date. How do I do that. I tried doing something like the below in the constructor but it won't work, datePicker.SelectedDate = DateTime.Now.Date; or datePicker.DisplayDate = DateTime.Now.Date; ...

WPF MVVM Multithreading Issue

Hi all. I've seen other issues similar to mine, but i haven't seen any that i can apply to make my code work. So i'm new to MVVM, and i'm trying to get some stuff that's executing in a background thread to update on my UI. What i'm noticing is that the first time bring up the UI, and the background thread executes the first time, if th...

Force close all open popups from code

I want to cause all open popups (with StaysOpen == false) to close from code. Basically I want to simulate the user clicking the mouse (which would close the popups) from code. I don't need to actually simulate the click, I just need the resulting behavior. I've thought about just going through the visual tree looking for popups and c...

Toolbar Button with Context Menu? Like New Project Button in Visual Studio.

I need a toolbar button similiar to the "New Project" button in the standard Visual Studio toolbar. When clicked, it pops up a dialog. However, it also has a small little down-arrow next to the icon graphic that, when clicked, expands a context menu with more options. Is there a standard control available with this functionality? ...

WPF Databinding TextBox to integer property in another object

I have what I think is a very simple databinding question (I'm still new to WPF). I have a class (simplified for this question) public class ConfigurationData { public int BaudRate { get; set; } } In MainWindow.Xaml.cs I have a private member variable: private ConfigurationData m_data; and a method void DoStuff() { // do...

Get result of a Binding in code

I'm probably searching for this the wrong way, but: is there any way to get the resulting value of a binding through code? Probably something glaring obvious, but I just can't find it. ...

Loading the list of items asynchronously in a WPF listbox using Dispatcher

Hi All, I am working on creating a WPF solution which uses MVVM pattern to load searched items in a search control asynchronously. The search control which is a WPF usercontrol is created with a textbox to enter search text and search button and a hidden listbox which would be visible when it loads the searched items list in it. This us...

XAML - is LayoutRoot mandatory?

When you create a XAML page in Silverlight or WPF, the system creates a top level container called "LayoutRoot". Is there anything special about this name, or can the top level container be called anything (or even nothing)? ...

How do i force a wpf window/control refresh of disabled elements

I was pulling out my hair trying to figure out why the normal Dispatcher.Invoke command did not work for redrawing my window, but now I the issue seems to be related to the content being disabled. I'm using the Dotnet 4.0 full framework. If i use private void DoSomething() { HandleBusyEnableDisable(false); DoSomethingThatKeepsItB...

error in my byte[] to WPF BitmapImage conversion?

I'm saving a BitmapImage to a byte[] for saving in a DB. I'm pretty sure the data is being saved and retrieved accurately so it's not an issue there. On my byte[] to BitmapImage conversion I keep getting an exception of "System.NotSupportedException: No imaging component suitable to complete this operation was found." Can anyone see w...

Fastest way to communicate between c++ and c#

We are building a new vision inspection system application. The actual inspection system needs to be c++ for a number of reasons. For that system we will be using Boost & Qt. For our UI, we are currently looking at using WPF/C# for the UI and SQL based reports. The complicating factor that UI has to run both local on the same box as ...

Is there a way to underline one character in a WPF TextBlock?

Is there a way to apply an underline text decoration to one character only in a TextBlock (or any amount less than the full block)? I have some text that I want output as "this worf is misspelt" and have the f in worf underlined. I know you can do: TextBlock47.TextDecorations = TextDecorations.Underline; but I don't want the entire ...

[WPF] ListView Losing Selection before Start Drag

I got a ListView Like the following. The User is supposed to select some Items and dragDrop to somewhere else. This does not require CTRL+click which is good. but after all the selection are made, when I try to start drag, the left click un-selects teh item that got clicked. How can I make this behave like windows explorer, so the select...

In WPF, how do I set a button's click event to change a grid's visibility?

I'm trying to set a button's event to change a grid's visibility using just XAML. I'm pretty sure I should be using an EventTrigger, but I couldn't get that to work so my most recent attempt is to create a DataTrigger that is bound to a field in the view-model: <Style x:Key="PersonalInfoGridStyle" TargetType="{x:Type Grid}"> <Style....

3D is not rendering in WPF Application

I am trying to render 3D object using the below code. But when I run the application, nothing is displayed. It seems to be blank. Am I missing anything? <Page x:Class="SampleWpfApplication.DemoPage3" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="DemoPage3"...

Is there anyway of consolidating similar data bindings and/or triggers in XAML?

I have a user control that hosts other controls. The way I implemented this is via data templates that define the control that should be associated with a specific view-model. These view-models have similar properties and interaction triggers. Please see XAML snippet below. The problem with this approach is that I would have to copy-pas...