wpf

WPF: On-screen validation

What technique or library do you recommend for on-screen validation. That is, validation that is very visible to the user. My requirements: The validation must have a way to indicate to the user which fields have a problem. The validation must have a way to indicate to the user how to fix the problem. The validation must support compa...

What is the most straightforward way to produce an XPS document (for printing) that has one picture/page?

I am trying to print captured images from a WPF application - it seems the approach to take is to create an XPS document and then send that to the printer. I have found some samples that involve using a DrawingVisual and adding that to the document, but after that I am unsure of how you set pagination, etc. Another example I have seen i...

Hierarchical data problems in MVVM.

Do you think this Model-ViewModel implementation is correct? Note that Stars (in the VM) is an ObservableCollection of VMs inside another one, and i feel like it decouples the VM from the M because when removing an element from Stars, i still have to delete it's model manually. Any ideas on how to improve this without using OnCollectio...

Is the PnP WPF/Silverlight Composite Application Guidance appropriate for role-based UI composition?

I'm developing a line-of-business application using WPF, possibly multitargeting SL as well. One of the requirements is that UIs be composed based on user roles/rights. For example, if the user is a salesperson, she shouldn't see any of the accounting components. If the user is an accounting clerk, that user will see some accounting comp...

WPF IsEditable ComboBox ErrorTemplate

Hello, I have a ComboBox with IsEditable="true". I'm trying to set an error template on the ComboBox. This is my error template that I have in my Window.Resources <ControlTemplate x:Key="error"> <Border BorderBrush="Red" BorderThickness="1"> <AdornedElementPlaceholder x:Name="adorner" /> <...

Replaced ItemsControl with ListBox and the item selection + ListBox height seems broken...

Hello, I have loaded this project into Visual Studio => http://sites.google.com/site/huyphamproject/Home/MyDashBoard.zip I have replaced all ItemsControl declaration in the main xaml file with ListBox so I have a SelectedItem property which I would need to use it with mvvm + datatemplate. When I select now one item in the ListBox-dash...

Binding to the selected item in an ItemsControl

I created a custom ComboBox as follows: (note, code is not correct but you should get the general idea.) The ComboBox contains 2 dependency properties which matter: TitleText and DescriptionText. <Grid> <TextBlock x:Name="Title"/> <Grid x:Name="CBG"> <ToggleButton/> <ContentPresenter/> <Popup/> </Grid> </Grid> I want...

System.Windows.Application.GetResourceStream returns null

If I debug a WPF-application with Catalog.xaml as Content, I can't get the resource stream of it - GetResourceStream returns null: var uri = new Uri("/Assembly;component/Catalog.xaml", UriKind.Relative); var foo = System.Windows.Application.GetResourceStream(uri); foo is null. What am I doing wrong? ...

WPF - MVVM - What are the pros and cons of the various view creation techniques?

I've been using MVVM for the past two years and it has certainly evolved for the better since that time. As I read though the hundreds of MVVM articles and stackoverflow questions, I've noticed that there appears to be more and more articles that describe the view/viewmodel relationship and creation as ViewModel first or View first. Thes...

Simulating an Active Directory Login in Dev/Test Environment

Currently building a WPF app that will run in an environment where the user logs into Windows PC which is on a domain (DC). The app will ask the user to enter their login and password again when it starts up, and the login/password will be verified against Active Directory (forgive me if my terminology is not correct here). The login i...

Need a way to center a TextBox under a Canvas in WPF Designer

I'm new at using the WPF Designer in VS2008 and I know very little about it right now. I'm trying to learn via experimentation. Below is my XAML (generated mostly by VS): <Grid> <Grid.RowDefinitions> <RowDefinition Height="478" /> <RowDefinition Height="64*" /> </Grid.RowDefinitions> <Grid.ColumnDefinitions>...

How do I bind element widths where "Auto" width behaviour is required?

I wish to have a set of elements have the same width, I can not simply put them in a grid as this is a content control and the elements being bound is unknown. As a simple example, how do I bind all widths of the first child of each stack panel together along with the second element. <StackPanel> <StackPanel Orientation="Horizo...

Grow/Shrink WPF Animation

Hi, In WPF, when a user gets focus in a TextBox, I would like some animation that would make the TextBox becomes multiline and make its width bigger (while he is typing) and when the focus is lost, that the textbox goes back to its original size. The size is unknown. Also, ultimately, that TextBox needs to be within a WPF Datagrid. I...

How can I speed up xaml creation in VS 2008?

Ok I know about XAML Power Toys, and thats pretty cool, but still kind of cumbersome for me. I like code snippets in the C# code view, but I can't don't know how to do that in xaml designer. What other options do I have? Is there a simple way to add maybe code snippets? Instead of typing out all the column and row definitions of a grid...

How to force WPF UI element to use resources from the theme, ignoring app's resources

Is there a way to make a WPF element use (explicitly or implicitly) the resources located in themes even if app.xaml provides resources with the same 'key'-s? I have all of the default controls restyled, and all those styles are merged to the app's ResourceDictionary. Now I have one single XAML file that has a single element which I'd l...

Resizable WPF Grid inserts blank lines between rows and columns depending on actual size

Hello, I have a Grid displaying rectangles. The grid can be resized and is supposed to display adjacent rectangles without any gap. However, depending on the actual size of the grid, blank lines appear between the rows and columns of the grid. I guess this is to make up for sizes where the width isn't a multiple of the number of column...

WPF Toolkit DataGrid: how to get ColumnHeader width to be the same as GridColumn width

For my WPF Toolkit DataGrid I use the following custom column header style: <Style x:Name="ColumnStyle" x:Key="ColumnHeaderStyle" TargetType="my:DataGridColumnHeader"> <Setter Property="ContentTemplate"> <Setter.Value> <DataTemplate> <StackPanel Orientation="Vertical" HorizontalAlignment="Stretch"...

What is the simplest way to print a series of full-page images from a WPF application?

I have a series of images (just stored locally on disk) that I would like to print, one-per-page, possibly scaled up/down if necessary and centered. What is the most straightforward method of doing this from a WPF application? Is it to somehow create an XPS document and if so then how? If not, what other possibilities are there? (e.g...

Dependency Property and ViewModel initialization problem

I am trying to add my own ItemsSource to provide a list of GraphViewModels to a chart. I dont think I have it quite right though, as when I create my first GraphViewModel and add it to the Graphs, my DP is updated, but OnGraphsCollectionChanged is not called. How is this supposed to work? If I add graphs to my VM property via a button ...

How to use DisplayMemberPath to show an item in a specific column

I have a ListView with several GridViewColumns (Title, Start, Due). So how can I bind an object with a string Title, datetime Start, and datetime Due. In procedural code I have already stated: lvwFill.ItemsSource = assignments.ListAssignments(); //Returns a List<Assignments> So now my XAML is: <ListView x:Name="lvwFill">...