wpf-4.0

Coerce a WPF TextBox not working anymore in .NET 4.0

为君一笑 提交于 2019-11-27 05:36:59
In my WPF application I have a TextBox where the user can enter a percentage (as int, between 1 and 100). The Text property is databound to a property in a ViewModel, where I coerce the value to be in the given range in the setter. However, in .NET 3.5, the data is not shown properly in the UI after being coerced. In this post on MSDN , Dr. WPF states that you have to manually update the binding so the correct will be shown. Therefore, I have a TextChanged handler (in the View) which calls UpdateTarget() . In code: View XAML: <TextBox Text="{Binding Percentage, Mode=TwoWay, UpdateSourceTrigger

How to grow/shrink a TextBlock (Font Size) to the available space in WPF?

六眼飞鱼酱① 提交于 2019-11-27 03:02:55
问题 I've seen this question asked a lot, however, to the opposite of what I'm looking for. While other people want a control to size itself based on the size of text, I'm trying to figure out is if there is a way to grow the size of text to the amount of space available. Take the idea of a digital clock window and you want the numbers stating the time to grow (or shrink) based on the size of the window the clock is in. If there isn't a way to automatically do this any pointers to a programmatic

filter wpf datagrid values from a textbox

◇◆丶佛笑我妖孽 提交于 2019-11-26 23:06:10
问题 I have a textbox and a Datagrid. The datagrid has two columns name and Email address. I want to Filter the datagrid values with the value in the textbox. 回答1: You can use a ICollectionView for the DataGrid ItemSource then you can apply a Filter predicate and refesh the list when needed. Here is a very quick example. Xaml: <Window x:Class="WpfApplication10.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" Title=

WPF4 DataGridHeaderBorder in a xaml Style

偶尔善良 提交于 2019-11-26 22:08:18
问题 Making a separate question, related to comments on the answer to WPF 4: What happened to DataGridColumnHeader? It appears I can use DataGridHeaderBorder in a UserControl, stand-alone in a ResourceDictionary, but not in a Style's setter of a Template. <ResourceDictionary xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" > <!-- Works --> <DataTemplate x:Key="yomama"> <DataGridColumnHeader /> </DataTemplate> <!-- Compile

Coerce a WPF TextBox not working anymore in .NET 4.0

你离开我真会死。 提交于 2019-11-26 11:38:32
问题 In my WPF application I have a TextBox where the user can enter a percentage (as int, between 1 and 100). The Text property is databound to a property in a ViewModel, where I coerce the value to be in the given range in the setter. However, in .NET 3.5, the data is not shown properly in the UI after being coerced. In this post on MSDN, Dr. WPF states that you have to manually update the binding so the correct will be shown. Therefore, I have a TextChanged handler (in the View) which calls

Difference between ObservableCollection and BindingList

依然范特西╮ 提交于 2019-11-26 00:57:36
问题 I want to know the difference between ObservableCollection and BindingList because I\'ve used both to notify for any add/delete change in Source, but I actually do not know when to prefer one over the other. Why would I choose one of the following over the other? ObservableCollection<Employee> lstEmp = new ObservableCollection<Employee>(); or BindingList<Employee> lstEmp = new BindingList<Employee>(); 回答1: An ObservableCollection can be updated from UI exactly like any collection. The true

Difference between ObservableCollection and BindingList

爷,独闯天下 提交于 2019-11-25 20:21:02
I want to know the difference between ObservableCollection and BindingList because I've used both to notify for any add/delete change in Source, but I actually do not know when to prefer one over the other. Why would I choose one of the following over the other? ObservableCollection<Employee> lstEmp = new ObservableCollection<Employee>(); or BindingList<Employee> lstEmp = new BindingList<Employee>(); Eilistraee An ObservableCollection can be updated from UI exactly like any collection. The true difference is rather straightforward: ObservableCollection<T> implements INotifyCollectionChanged