wpf

How to select File Menu Items using Keyboard in WPF and C#?

I am developing a WPF UI application . I have a menu on top of the screen, which has File, Help menuitems. In file -> Backend features (shortcut key is ctrl + B), Exit (Ctrl + x) sub menu items. when clicked on any sub menu item, the corresponding window opens. So, with out using mouse, by pressing ctrl + B or Ctrl + x, how can the ...

How do I implement web part functionality in WPF?

I'm working on a WPF application that works with several different types of data, and I'd like to implement the UI in a manner similar to SharePoint's implementation of web parts, or perhaps something like Google's gadgets. Is there a pattern or set of controls I can purchase that will help me implement this? Any pointers/suggestions/we...

WPF parameterized resource

I have a listbox with a datatemplate that contains a number of comboboxes. I've currently got a datatrigger on the datatemplate to change the bindingsource (to a different objectdataprovider resource declared in my xaml) of one of the comboboxes depending upon the selectedvalue of another combo. What I'd like to do is have a parameter...

What is the static variable initialization order in C#?

DependencyProperty.AddOwner MSDN page offers an example with two classes with static members, and the member of one class depends on the member of the other class for initialization. I think MSDN is wrong - the initialization order of static variables is unreliable in C# just like it is in C++ or anywhere else. I'm probably wrong because...

MVVM: Tutorial from start to finish?

I'm a C#/Windows Forms programmer with more than 5 years experience. I've been investigating WPF using the MVVM (Model-View-ViewModel) design pattern. I have searched the Internet for tutorials. I have even watched the entirety of Jason Dolinger's awesome video. Although I have found many, I have not found one that takes me from start to...

WPF-application memory leak

Hello. After certain action (pressing a button that starts a sequence of calculations) in the WPF-application a memory leak occurs (it is visible in the task manager in vm size section) approximately on 10 mbytes after each pressing of the button. The sequence of calculations does not contain errors. The use of memory profiler (.NET Memo...

WPF layout on a Window

I have a couple of listboxes on a WPF Windows, with Height="Auto" Width="Auto" set on the form The form sizes perfectly on different resolutions, but the problem is that when I press the maximise button a thick "Black L" is visible while the form resizes. I have seen this on quite a few WPF applications, but not had to solve the proble...

WPF LsitView grows bigger than it's containing Canvas

I have a ListView which is using a gridView to display a DataTable and when new rows are added to the DataTable the LsitView grows as expected but when it reaches the bottom of the Canvas it carries on growing. I want it to stop when it reaches the height of the Canvas, how can Iconfigure this? The Canvas has a dynamic height which is ...

A more elegant ListView requery

I need to refresh my ListView everytime the another control's IsChanged event is fired. I googled on how to do that, and I saw a stackoverflow link that led me here One of the answers worked: listView.ItemsSource = listView.ItemsSource Is that really the only way to refresh my listview? It feels kinda off. ...

Data added to datagrid not visible in UI in WPF in MVP

Hi, In a WPF application, I have to display data to a log window using data grid.. Every log message should be added to the logwindow and needs to be displayed. My Xaml is : <ListView x:Name="lstViewLogWindow" ItemsSource="{Binding}" Height="152" IsSynchronizedWithCurrentItem="True" MouseEnter="lstViewLogWindow_MouseEnter" Mouse...

Get the Style of a Control {StaticResource {x:Type TextBlock}} in code behind

I want to grab the default Style for a TextBlock in code behind without ever having adding a custom default textblock style to resources in xaml I've got a method like this: public TextBlock DrawTextBlockAtPoint(string text, Style textblockStyle) { //... } that I want to provide an override that just uses the regular TextBlock style...

Keyboard shortcuts in toolbar

I am writing a WPF application with just a few commands, so I am using a toolbar, without a menu. I would like to assign ctrl-key shortcuts to the buttons on the toolbar. Is there a simple way to do this, without having to create routed commands or ICommands just to support the shortcuts? I would prefer to do it in XAML, rather than code...

Can't get ListBox and UpdateTarget to work

Here are the relevant parts of the XAML file: xmlns:local="clr-namespace:BindingTest" <ListBox x:Name="myList" ItemsSource="{Binding Source={x:Static local:MyClass.Dic}, Path=Keys, Mode=OneWay, UpdateSourceTrigger=Explicit}"> </ListBox>...

Using wpf to draw scaled backgrounds on screen using minimal resources

I want to draw the same background on multiple windows for example the background could be concentric circles, a multi colored grid or any mathematical shapes combined. These backgrounds are customizable from an external routine which is in a different module. When i instruct the external routine to change the background all the windows ...

How do I create a Style within a WPF UserControl?

I want to set the style of some controls on my UserControl, but can't seem to find the right syntax: <UserControl x:Class="HiideSRM.WIDSModule.BiometricStatusIndicator" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" ...

In WPF, how can I handle an event in an ItemsControl ControlTemplate

Hi, I'm trying to handle an event inside an ItemsControl ControlTemplate. I have assigned the MouseUp and MouseDown events of a button (btnRight below). The problem is that when I click on the button, the event never reaches my code-behind. How do events in ControlTemplates work and what do I need to do to hook this up? I've tried assig...

WPF: Problem with ItemsControl datatemplate as a user control

This works fine: <ItemsControl ItemsSource="{Binding Persons}"> <ItemsControl.ItemsPanel> <ItemsPanelTemplate> <StackPanel Orientation="Vertical" /> </ItemsPanelTemplate> </ItemsControl.ItemsPanel> <ItemsControl.ItemTemplate> <DataTemplate> <StackPanel Orientation="Horizontal"> <TextBlock ...

How can I reference an attached property as the source of a data binding?

Here's a much-abbreviated sample of my code. <Grid> <Polygon Name="ply" Grid.Column="2" Grid.Row="0" Grid.RowSpan="3" Fill="Orange" Stroke="Orange" Points="0,1 1,3 2,2 2,0 0,0" /> <Line Grid.Column= "{Binding ElementName=ply, Path=Grid.Column, Mode=OneWay}" Grid.Row= "{Binding ElementName=ply, Path=Grid.Row, Mode=On...

Where to download XAMLPad?

If anyone know where to download XAMLPad? Or you know better alternative to test WPF? Thanks ...

WPF data-binding with multiple dependencies?

I believe this code may require more effort to comprehend than average, so I'm using contextual code-comments to explain my predicament in an effort to make it a little easier to understand my question. public class MyControl : System.Windows.FrameworkElement { public double Property1 { get; set; } public double Property2 { ge...