wpf

How to find a resource in a UserControl from a DataTemplateSelector class in WPF?

I'm creating my own UserControl and I have two different DataTemplates under the UserControl.Resources section in my XAML. I want to choose between these two datatemplates depending on the value of a property on objects displayed in a listview. I do this by creating a custom DataTemplateSelector class and overriding the SelectTemplate me...

Equivalent to SuspendLayout and ResumeLayout in WPF

Specific scenario. ControlA changes a value that causes ControlB (a subclass of scrollviewer) to refigure it's viewport, offset, and extent, and then fire the ScrollableChanged event. ControlB also catches the "ScrollableChanged" event and is programatically scrolled to a determined offset. This creates this awful double redraw that w...

WPF binding ComboBox to enum (with a twist)

Well the problem is that I have this enum, BUT I don't want the combobox to show the values of the enum. This is the enum: public enum Mode { [Description("Display active only")] Active, [Description("Display selected only")] Selected, [Description("Display active and selected")] ActiveAndSelected }...

How can I set the binding of a DataGridTextColumn in code?

I'm using the toolkit:DataGrid from CodePlex. I'm generating the columns in code. How can I set the equivalent of {Binding FirstName} in code? Or alternatively, how can I just set the value, that's all I need to do, not necessarily bind it. I just want the value from my model property in the cell in the datagrid. DataGridTextColumn d...

Setting Window.Content doesn't destroy the UI that was there before?

Hi, I'm loading a XAML file with XamlReader and setting the returning object to the window's Content property. While this seems to work well, it doesn't quite do what I expect. If the window's original XAML contains keybindings or buttons, they seem to still exist. Keybindings still work and any Button objects in code are still valid. I...

Refresh WPF UserControl via XAML

Hello! I'm using WPF within Visual Studio 2008. I have a simple WPF UserControl with the following code: public partial class UserControl1 : UserControl { public UserControl1() { InitializeComponent(); Composite = new Composite(); } protected override void OnRender(DrawingContext drawingContext) { ...

SelectedItem Trigger

Can I use a trigger on the SelectedItem property in any control that supports SelectedItem? <Trigger Property="SelectedItem" Value="{x:NotNull}" > </Trigger> What I want is when the SelectedItem is Not null for the trigger to fire. Tnx ...

Enumerating translated .resx resources at runtime in WPF application

I've been doing localization for my WPF application by storing strings in .resx files. My default (english) string resource is strings.resx. For other languages are called strings.fr-FR.resx for French, strings.es-ES.resx for Spanish and so on. This method of localization has been great as my app will automatically load up the right str...

UserControl as a TabItem

Hi, I've been playing with WPF and I'm not sure what I'm trying to do is possible. So is it possible to have a usercontrol describing a tabitem? I've tried but without success. Right now I use user controls for the content but I would like to change that to be more generic. ...

Passing the current mouse position to a ViewModel?

Hi, In my MVVM application, I have a Direct3d render window that shows a bunch of 3d meshes in a scene. In that render window, I want to be able to click on one of those 3d meshes in the scene and move it around, having it follow the mouse cursor. This is typical 3d editor stuff, moving a mesh along in screen space. So I need to be able...

What are the three top Blogs for WPF?

I have several bookmarked, but only have so much time in a day to read/study blogs. If I were to pick three blogs to read on a daily basis for deep understanding of WPF what should I read? ...

How can I bind WPF Grid Column Width in code?

In WPF I have a Grid with a number of columns defined and the Width of each column is bound to the width of a DataGrid column, like so: <Grid.ColumnDefinitions> <ColumnDefinition Width="{Binding ElementName=dataGrid, Path=RowHeaderWidth}" /> <ColumnDefinition Width="{Binding ElementName=Column0, Path=ActualWidth}" /> <ColumnDef...

What, if any, technology is going to replace ASP.NET?

WinForms has given way to WPF and new models such as MVVM, that better enable Test Driven Development, work very nicely with WPF. Also, it seems to me that ASP.NET is very closely aligned with the WinForms way of doing things, for example event handlers in the code-behind which is linked using inheritance or partial classes. With WPF a...

Databindings don't seem to refresh

For some reason I'm really struggling with this. I'm new to wpf and I can't seem to find the information I need to understand this simple problem. I am trying to bind a textbox to a string, the output of the programs activity. I created a property for the string, but when the property changes, the textbox does not. I had this problem w...

How to Create Treeview like Vista Treeview in wpf.

I am developing an application in wpf. I already created a treeview like vista.Now i want to open my Default My Pictures folder when i load the treeview. I am getting treeview like Desktop-->C:\ D:... Now i want to show My Pictures under Desktop. Is there any way to do that. Suggestions plz. Thanks in advance. ...

How can I find an item in a WPF ListBox by typing?

Most list boxes allow you to find items within them by typing the first letters of the displayed text. If the typed letters match multiple items, then you can keep adding letters to narrow the search. I need to do this in a WPF ListBox. However, the items aren't plain strings -- they're custom objects that I present using a DataTempla...

How to I respond to changed cells in the CodePlex WPF DataGrid?

In my view, I've implemented a the WPF DataGrid from CodePlex: <toolkit:DataGrid x:Name="CodePlexDataGrid" Style="{StaticResource ToolkitDataGrid}" ItemsSource="{Binding Customers}"/> It is bound to an ObservableCollection in my ViewModel: private ObservableCollection<Customer> _customers; public ObservableCollection<Custom...

WPF: adding UIElements to a ListBox whose ItemsPanelTemplate is a canvas?

Hello, I'm working on a ListBox that overrides its' ItemsPanelTemplate to use a Canvas instead of a StackPanel. ListBoxItems have a DataTemplate that uses a converter to define the look and position of each ListBoxItem on the canvas. When I add an item to the collection that the ListBox is bound to, I'd like to be able to add other UI...

How do I pass the information from View to ViewModel with DelegateCommand?

In my View, I have a button. When the user clicks this button, I want to have the ViewModel save the context of the TextBlock in the database. <StackPanel HorizontalAlignment="Left" VerticalAlignment="Top"> <TextBlock Text="{Binding FirstName}"/> <TextBox Text="Save this text to the database."/> <Button Content="Save" Comma...

What is the best way for the ViewModel to manipulate the View?

I understand that in the MVVM pattern, that a ViewModel should know nothing about the View. So there seems to be two ways that the ViewModel can cause something particular to happen on the UI, consider this common flow of events: user types something in a textbox user clicks button button calls DelegateCommand called "Save" on viewmod...