wpf

What is the difference between a RoutedCommand and a RoutedUICommand?

I have tried to do some reading about it, but I failed to find documentation that explains the difference between RoutedCommand and RoutedUICommand satisfactorily. ...

ControlTemplate for second level of TreeView

I'm trying to create a TreeView which has two levels but I'm getting nowhere. I have an ItemTemplateSelector (which works - selecting either of the first two templates listed below), but I can't get the children to populate using a DataTemplate. This is my code: public class PlannedMealGroup : INotifyPropertyChanged { public Obs...

Bubbling scroll events from a ListView to its parent

In my WPF application I have a ListView whose ScrollViewer.VerticalScrollBarVisibility is set to Disabled. It is contained within a ScrollViewer. When I attempt to use the mouse wheel over the ListView, the outer ScrollViewer does not scroll because the ListView is capturing the scroll events. How can I force the ListView to allow the s...

Setter precedence overriding in WPF?

Look at the line "THIS LINE ####" in following example. <ListBox Grid.Row="0" x:Name="listBoxServers"> <ListBoxItem HorizontalContentAlignment="Stretch"> <StackPanel> <TextBlock><Run Text="My computer"/></TextBlock> <TextBlock Foreground="{DynamicResource {x:Static SystemColors.ControlDarkBrushKey}}"> <Te...

WPF: Error using a custom control in the ItemTemplate of another custom control

I have a custom control library where I have several custom controls that I use in my main application. I have a simple custom control that lets the user select pen thickness values from a combobox. Now, I am creating a new custom control, based on a listbox, and I want to include the pen thickness combobox in the new custom control's It...

Using Linq to filter possible values of System.Windows.Forms.Keys

I'm creating an options dialog using WPF that lists possible keys so that the user can assign the program's hotkey. I'm attempting to filter all of the possible values of the System.Windows.Forms.Keys enumeration down to just A-Z and F1-F12, and then bind that list to a ComboBox. Here's my code so far: Regex filter = new Regex("(^[A-...

How do I make an asterisk line up with surrounding text in WPF?

I'm trying to make an asterisk line up vertically with surrounding text/graphics rather than above it. I thought applying a negative BaselineOffset would be the solution, but it seems to have no effect. Here's the documentation for the TextBlock.BaselineOffset property: Property Value Type: System.Double The amount by which ...

WPF MVVM Routed Events

Hi everyone, There are a lot of discussions about M-V-VM and Command binding (RelayCommand) but not a lot has been covered on Routed Events binding to a handler in a M-V-VM pattern. I want to find what is the best approach. Here is an example of RoutedEvent binding using a custom event and a bound event handler to the VM. <Navigation:...

WPF Change a rectangles points at runtime

Hi All, I have a WPF app in which I need to programatically manipulate at runtime. What I thought of doing is having a Path with 4 line segments like so: Canvas.Left="324" Canvas.Top="247"> <Path.Data> <PathGeometry> <PathFigure IsClosed="True"> <LineSegmen...

Designing with Blend but loading styles at runtime

I have a large WPF application and am trying to use Blend 3 to speed up my UI design on some portions of it. The problem I run into is that I have different skins that the user can use, so I load the ResourceDictionaries and Converters at runtime at the Application level. Because of this, when I open a .xaml file in Blend, it can't f...

WPF ScrollView resize offset problem

I have the following test sample <Window x:Class="WpfScrollTest.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title="Window1" Height="200" Width="200"> <Border> <StackPanel> <Label Width="Auto" Height="Auto" Content="...

Online resources for premade WPF styles/control templates?

When it comes to UI design I generally don't care to do custom styling (appearance-wise), I'm not much of an artist and I hate trying to come up with interesting color schemes and the like. Are there any online repositories of premade WPF styles and/or control templates? I could have sworn I saw one before but I can't find it now, it mig...

recommendations for material on data binding

any good recommendations for databinding. i am starting to look into WPF more and i want to fully understand the how databinding work under the hood here. also, WPF is just one example as i assume there is a common pattern with tech like asp.net mvc data binding, etc. ...

Does anyone have a simple example of a UserControl with a single ContentPresenter?

So far, I have this: <UserControl x:Class="MyConcept.ExpanderPanel" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"&gt; <Grid> <Border Style="{StaticResource Border_PanelStyle}" CornerRadius="3" /> <ContentPre...

WPF Auto search combobox item

In WPF, when I type some text in combobox, it will highlight the item starting with the text I entered. This highlighting will search the whole text I have entered in the combo box. But instead I want the text search to match only the first letter. How to do this? Sample Code to re-create the problem: XAML: <Window x:Class="ComboTest...

TreeView items disappear

I have a TreeView that is generated in code, and will look like this in the end: <TreeView> <TreeViewItem Header="X"> <TreeViewItem Header="Y"> <TreeViewItem Header="Z"> <StackPanel Orientation="Horizontal"> <TextBlock Width="100" Text="SomeText" /><TextBox Width="100" Text="TextInBox" /> </StackPan...

Viewbox alternative using Winforms

Hello, I'm getting used to WPF and it's sometimes very painful to come back to Winforms development. I'm looking for some kind of alternative to the WPF Viewbox for Winforms. Do you have any idea? My major issue is that I need to update dynamically the size of the Font used in a Label control and/or a Picture control. ...

WPF Richtextbox FontFace/FontSize

Hello, I am currently trying to create some basic word processor features in a WPF project. I am using a RichTextBox and am aware of all of the EditingCommands (ToggleBold, ToggleItalic...ect.). The thing I am stuck on is allowing the user to change the fontsize and font face like in MS Office where the value changes for only the selecte...

wpf events and chain of responsibility pattern

do routed events from wpf have something in common with the chain of responsibility pattern ? i googled for this and i don't see anyone talking about this :S, although i though that the routed events are an implementation of that pattern ...

WPF: Execute a Command Binding in a search field when pressing the enter button

I have a search field in my WPF app with a search button that contains a command binding. This works great, but how can i use the same command binding for the text field when pressing enter on the keyboard? The examples I have seen are all using the Code behind with a KeyDown Event Handler. Is there a smart way to make this work only wit...