binding

OneWay binding stops working after the target manually updated

爷,独闯天下 提交于 2019-12-22 04:42:31
问题 I have such WPF binding code: TestModel source = new TestModel(); TestModel target = new TestModel(); Bind(source, target, BindingMode.OneWay); source.Attribute = "1"; AssertAreEqual(target.Attribute, "1"); target.Attribute = "foo"; source.Attribute = "2"; AssertAreEqual(target.Attribute, "2"); The second assertion fails! This seems odd for me. Also, I tried 'OneWayToSource' instead of 'OneWay', and all works as expected. Bind(source, target, BindingMode.OneWayToSource); target.Attribute = "1

Wpf GridSplitter replaces binding on row.height property

纵然是瞬间 提交于 2019-12-22 04:28:27
问题 I'm having a hard time with grid splitter. I've bound the RowDefinition.Height dependency property to the clr property of the model as presented below. <Grid.RowDefinitions> <RowDefinition Height='{Binding Path=Height, Mode=OneWay}' /> <RowDefinition Height='*' /> </Grid.RowDefinitions> This works fine just until the GridSplitter is used. When the height of the row is changed manually with GridSplitter , it replaces the binding with the new fixed size (and removes the binding). Have you got

WPF DataGrid: Binding a Collection Property to Column

蹲街弑〆低调 提交于 2019-12-22 04:25:14
问题 I have a Class called Person: public class Person { private string _Name; private ObservableCollection<Smartphone> _Smartphones; // Properties } public class Smartphone { private string _Manufacturer; private bool _IsWorking; // Properties } And in my View I have a DataGrid. My Question is: Is there a way to make my DataGrid look like this: All Persons have the same Smartphones in their Collection, but with different values vor "IsWorking"... EDIT: I've tried it with a DataGrid in a DataGrid

Winforms ComboBox SelectedItem changing does not affect the BindingSource

﹥>﹥吖頭↗ 提交于 2019-12-22 04:24:06
问题 I am making C# / WinForms application. The problem I couldn't solve (yet) is that when I change the SelectedItem of ComboBox programatically, it is changed until the ComboBox loses the focus, after that it "reminds" its value before assigning the SelectedItem. I think that it takes the old value from binding source. When choosing an item using UI the underlying bound object is updated normally but it doesn't so when I'm assigning new value to SelectedItem programatically. Just for additional

How to calculate a value in WPF Binding

半城伤御伤魂 提交于 2019-12-22 04:06:20
问题 I have an app which uses two sliders to generate a product used elsewhere in the code. What I would like is to have the product value bound to a textblock or tooltip, for example, to look something like "10 x 15 = 150". The first part is easy, and looks like this: <TextBlock.Text> <MultiBinding StringFormat="{}{0} x {1}"> <Binding ElementName="amount_slider" Path="Value" /> <Binding ElementName="frequency_slider" Path="Value"/> </MultiBinding> </TextBlock.Text> But what's a nice easy way to

How to calculate a value in WPF Binding

梦想的初衷 提交于 2019-12-22 04:05:14
问题 I have an app which uses two sliders to generate a product used elsewhere in the code. What I would like is to have the product value bound to a textblock or tooltip, for example, to look something like "10 x 15 = 150". The first part is easy, and looks like this: <TextBlock.Text> <MultiBinding StringFormat="{}{0} x {1}"> <Binding ElementName="amount_slider" Path="Value" /> <Binding ElementName="frequency_slider" Path="Value"/> </MultiBinding> </TextBlock.Text> But what's a nice easy way to

Alternative to ElementName in x:Bind with DataTemplates

此生再无相见时 提交于 2019-12-22 03:59:11
问题 When using traditional {Binding} syntax you could specify element name to point to a specific control on the page, and be able to access its properties. For example if the page is named page you could do: {Binding ElementName=Page, Path=Name} With the {x:Bind} syntax it says With x:Bind, you do not need to use ElementName=xxx as part of the binding expression. With x:Bind, you can use the name of the element as the first part of the path for the binding because named elements become fields

Validation Binding on First Load

自闭症网瘾萝莉.ら 提交于 2019-12-22 03:56:30
问题 I'm still struggling with validation in WPF. I've got a custom validation rule which requires text to appear in a textbox i.e. it enforces a mandatory field constraint. <TextBox local:Masking.Mask="^[a-zA-Z0-9]*$" x:Name="CameraIdCodeTextBox" Grid.Row="1" Grid.Column="1"> <Binding Path="CameraIdCode" Mode="TwoWay" UpdateSourceTrigger="PropertyChanged" NotifyOnValidationError="True" ValidatesOnExceptions="True"> <Binding.ValidationRules> <localValidation:RequiredFieldRule /> </Binding

DataTrigger on Enums as the trigger value on a WPF Style

房东的猫 提交于 2019-12-22 03:24:50
问题 So here's what I'm trying to do in a little nutshell, I'm just gonna start with code and it will most likely make sense. <bl:InnerGlowBorder x:Name="glow" InnerGlowColor="Teal"> <bl:InnerGlowBorder.Style> <Style TargetType="bl:InnerGlowBorder"> <Style.Triggers> <DataTrigger Binding="{Binding ViewUnitStatus}" Value="UnitStatusModel.Pass"> <Setter Property="InnerGlowColor" Value="Green" /> </DataTrigger> <DataTrigger Binding="{Binding ViewUnitStatus}" Value="UnitStatusModel.Fail"> <Setter

WPF. How to stop data trigger animation through binding?

岁酱吖の 提交于 2019-12-22 03:19:27
问题 In WPF toolkit datagrid I have a data trigger bound to opacity of cell element. When UpVisibility changes to 1 the path become visible and the animation starts to fade it to 0. Which works. However my problem now - if I need to prematurely stop/cancel the fading and am setting UpVisibility to 0 the Path is still visible and fading as nothing happened.... How to drop opacity to 0 instantly using MyValue object ? <Path Data="M 5,0 0,10 10,10" Height="10" Width="10" Fill="Green" Opacity="