wpf

WPf : Binding with more than one property at a time

Hi, I have a list view in which I use binding to display my information. I use a simple data template. Is there a way to bind two data in one control. What I mean would to be replace something like : <TextBlock Text="{Binding LName}"/> <TextBlock Text=", "/> <TextBlock Text="{Binding NName}"/> to something like <TextBlock Text=...

Changing the start up location of a WPF window

I'd like to have a WPF window open in the top right part of the screen. Right now I can achieve that by opening the window and then moving it (via movewindow in user32.dll). However, this approach means the window opens in it's default location, fully loads, and then moves to the top right. How could I do I change it so that I could s...

Multi-Column Selector

Hi there. I am searching for some hybrid of ComboBox and ListView and I am wondering why there exists nothing like that, although I feel it's a quite natural wish to have it. In more detail: A WPF ItemsControl should have an ItemsSource of all applicable items. These items have multiple properties, say ID:int, Name:string and Descripti...

Select Individual XML Bound Items in TreeView

I am trying to learn to bind the following simple XML file to a WPF TreeView: <?xml version="1.0" encoding="utf-8" ?> <Profiles> <Customer> <Name>Customer1</Name> <Profile> <Version>1.0</Version> <DisplayText>DisplayText1</DisplayText> </Profile> <Profile> <Version>1.0</Version> <DisplayTex...

Change how items are displayed WPF list box

I have a WPF window which displays a ListBox. I've changed the ListBox's item template so that the list box displays rectangular items which can be selected. Now I'd like to modify the ListBox's ItemsPanelTemplate so that the items are displayed in a grid instead of either a vertical or horizontal list. Specifically I'd like the first i...

Dynamically changing the start up location of a WPF window

This is a follow up question to an answered question [here][1]. There the startup position of a WPF window was defined in XAML. Now I'm wondering how to change those properties in code? For example could I say something like: Window1.Top = 40 in the window load event handler? Or which window event would I need to set those for it dyna...

Problem with ItemTemplate TextBlock

Hi, i am trying to make an item template where some of the field in my stack panel can be empty. When it's empty, I would like to set the visiblility to collapsed. I tried putting triggers but it doesn't seem to work and I am not very familiar with this part of WPF Also, I would like to change the color of the background of this item w...

Is it possible to extend a ControlTemplate the same way you extend a Style in WPF?

So the thing is that I have a main ControlTemplate which defines the most basic stuff for the new button look we're designing. But I want to do 3 other control templates for this button so we can set different colors in those; but I don't want to copy paste the main ControlTemplate and change the color there, instead I want to "inherit" ...

YesNo MessageBox not closing when x-button clicked

When I open a MessageBox with options YesNo, the (usually) cancelling cross in the upper right is shown but has no effect. System.Windows.MessageBox.Show("Really, really?", "Are you sure?", MessageBoxButton.YesNo); If I offer YesNoCancel as options, clicking the cross closes the Dialog with DialogResult Cancel. System.Windows.Message...

WPF CreateBitmapSourceFromHBitmap memory leak

I need draw an image pixel by pixel and display it inside a WPF. I am attempting to do this by using a System.Drawing.Bitmap then using CreateBitmapSourceFromHBitmap to create a BitmapSource for a WPF Image control. I have a memory leak somewhere because when the CreateBitmapSourceFromBitmap is called repeatedly the memory goes up and ...

How can a WPF ListBox, with a custom ItemsPanel template, resize itself based on the size of its items

This is a follow up question to this, which was answered. Using the code <ListBox ScrollViewer.VerticalScrollBarVisibility="Disabled"> <ListBox.ItemsPanel> <ItemsPanelTemplate> <WrapPanel Orientation="Vertical"/> </ItemsPanelTemplate> </ListBox.ItemsPanel> </ListBox> you can create a list where the items populate...

WPF: How can I wrap the items in a ItemsControl in another Template?

I have an ItemsControl that contains items that each has its own DataTemplate. Each ViewModel class in the ItemsSource derives from a common ancestor that has a Header property. I want to wrap each item in a Expander control, but my problem is that I don't know how to 'carry over' each 'DataTemplate' to the DataContext of the expading p...

WPF designtime code

Hi, Does anybody know any pointers to knowledgebase for how to write design-time experience (i.e. VisualStudio 2008 design time) for WPF controls please? There are loads of references for creating the design-time code for Windows Forms controls, but hardly any for WPF ones. I have googled a lot for this, but with no good results. Ple...

What's the easiest way to do negation in triggers?

I want to do something like <DataTrigger Binding="{Binding Something}" ValueIsNot="{x:Null}"> ...

How to get something like PreviewSelectionChanged event in ListBox?

I need to perform some actions when list box selection is about to changed, but old item is still selected. Something like PreviewSelectionChanged. Does WPF allow such operation? I can not find such event in ListBox control. ...

WPF Data binding issue using mvvm pattern

I have created a user control "SearchControl"(which will be reused further in other screens as well. SearchControl -> <usercontrol name="SearchControl"......> <stackpanel orientation="horizontal"...> <TextBox Text"{Binding Path=UserId}"...> <Button Content="_Search" ....Command="{Binding Path=SearchCommand}"..> </...

DispatcherTimer eating up CPU over time causing WPF visual not rendering properly

I have a WPF app that uses DispatcherTimer to update a clock tick. However, after my application has been running for approx 6 hours the clocks hands angles no longer change. I have verified that the DispatcherTimer is still firing with Debug and that the angle values are still updating, however the screen render does not reflect the ch...

How to resolve bound object from bindingexpression with WPF?

Hi does anyone know if there are any inbuilt classes for resolving a bound object from a bindingexpression and it's DataItem and property path? I'm attempting to write a Blend 3 behavior for textboxes which automatically invokes methods on an object bound to the textbox Text property. The textbox is bound to a property on a viewmodel c...

WPF - Clearing only certain Resource Dictionaries

I am applying "themes" to my WPF app by clearing all merged dictionaries (Resources.MergedDictionaries.Clear()) and new ones based on the selected theme. Instead of clearing all dictionaries, I would like to clear only certain "theme-related" dictionaries, leaving others still loaded. How can I do that? I didn't find a way to differen...

Proper cleanup of WPF user controls

I am relatively new to WPF, and some things with it are quite foreign to me. For one, unlike Windows Forms, the WPF control hierarchy does not support IDisposable. In Windows Forms, if a user control used any managed resources, it was very easy to clean up the resources by overriding the Dispose method that every control implemented. I...