WPF Editable ComboBox

Here’s a basic MVVM compliant way of getting the behaviour you want: MainWindow.xaml <Window x:Class=”WpfApplication1.MainWindow” xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” Title=”MainWindow” Height=”350″ Width=”525″> <StackPanel> <ComboBox Margin=”30,5,30,5″ IsEditable=”True” ItemsSource=”{Binding Items}” SelectedItem=”{Binding SelectedItem}” Text=”{Binding NewItem, UpdateSourceTrigger=LostFocus}”/> <TextBox Margin=”30,5,30,5″ /> </StackPanel> </Window> MainWindow.cs public partial class MainWindow : Window, INotifyPropertyChanged { private string _selectedItem; private ObservableCollection<string> _items = new ObservableCollection<string>() { … Read more

wpf custom button best approach

Like you, when I was getting started and wanted to understand how / what was going on and working with templates, it took a lot of trial and error. Hopefully my research and some step-by-step components can help you customize to your liking and KNOWING where things are coming from. First, when trying to understand … Read more

How to show row-number in first column of WPF Datagrid

There might be an easier way to do this but I got it to work by using the GetIndex() method on the DataGridRow class. This returns the index in to the data source so might not be exactly what you’re after. the xaml <Window x:Class=”WpfApplication1.MainWindow” xmlns=”http://schemas.microsoft.com/winfx/2006/xaml/presentation” xmlns:x=”http://schemas.microsoft.com/winfx/2006/xaml” xmlns:sys=”clr-namespace:System;assembly=mscorlib” xmlns:local=”clr-namespace:WpfApplication1″ Title=”MainWindow” Height=”350″ Width=”525″> <DataGrid> <DataGrid.Columns> <DataGridTextColumn … Read more

How to draw arc with radius and start and stop angle

Providing a custom component turned out to be the best solution. I use it like this in my code <Controls:Arc Center=”{Binding Path=PreviousMousePositionPixels}” Stroke=”White” StrokeDashArray=”4 4″ SnapsToDevicePixels=”True” StartAngle=”0″ EndAngle=”{Binding Path=DeltaAngle}” SmallAngle=”True” Radius=”40″ /> SmallAngle when true will render the small angle between the points irrespective of order of StartAngle and EndAngle. When SmallAngle is false the … Read more