ivalueconverter

WPF Visibility Converter not Firing

蓝咒 提交于 2019-12-13 19:24:40
问题 I can't seem to get my visibilty converter to work. I think the issue is that i'm setting the relevant property in the constructor, so it's not picking it up down the line. Code is below, any suggestions as to how I can fix this? MainWindowViewModel: (this is the main page; clicking a button will open a second window) var newWindow = new SecondaryWindow { Title = title, DataContext = new SecondaryWindowViewModel{MyData = data, ShowAdditionalColumns = false} }; newWindow.Show(); Secondary

Joining 2 collections into datagrid using multibinding

谁都会走 提交于 2019-12-13 16:53:29
问题 I have 2 collections of data, the first one is only for group names and the second one is for values. I want to fill these data in a datagrid like this: groupId | group | store 1 | store 2 | store 3 | store 4 1 | grp 1 | | | | 2 | grp 2 | | | | 3 | grp 3 | | | | 4 | grp 4 | | | | I created a new property in the modelview which creating a new collection of the required rows. Then I tried to achieve it using multibinding and converters like this. <DataGrid> <DataGrid.Columns>

Is it guaranteed that on IValueConverter ConvertBack call other views would update?

血红的双手。 提交于 2019-12-13 07:45:41
问题 Is it guaranteed that on IValueConverter ConvertBack call other views would update and how to enforce it? I have 4 parameters in a List. Each pair of them can be calculated from another two in a manner like: A = f(a,b) B = f2(a,b) a = f3(A,B) b = f4(A,B) I have them all rendered in one in a ItemsControl. I created a IValueConverter that can Convert and ConvertBack on demand. During Conversion Back of one item values for other three are updated in the source List. I wonder if it is guaranteed

DataGrid DateTime IValueConverter, edit time only, preserve date

左心房为你撑大大i 提交于 2019-12-13 04:17:39
问题 I want to display a DateTime in two columns as Date and Time respectively. Updating the time column with input "HHmmss" updates the time, but resets date to current date. How can the date be preserved? public class TimeToStringConverter : IValueConverter { public string Format { get; set; } public object Convert(object value, Type targetType, object parameter, CultureInfo culture) { Format = "HH:mm:ss"; DateTime DateTimeValue = (DateTime)value; return DateTimeValue.ToString(Format); } public

how to pass value to converter which is a Property in the element which was bound

情到浓时终转凉″ 提交于 2019-12-13 01:26:08
问题 iv'e got a group of Shapes , i need to decide which stay visible and which hidden according to tow conditions (this will represent a dice visual ) (1) the value they receive via binding from their data context . (2) the value of their place in the group which i saved for each shape in it's Tag property i need the converter to get the Tag Property as a parameter for each Shape my binding :( INCORRECT ) <Style TargetType="{x:Type Ellipse}"> <Setter Property="Visibility" Value="{Binding Path=.,

Using Path=. and Converter inside Binding

 ̄綄美尐妖づ 提交于 2019-12-12 18:00:20
问题 I have trouble defining a trigger for TreeViewItems. I believe it is just some syntax problem, but I don't know what else to write... This is the Trigger: <DataTrigger Binding="{Binding Path=., Converter=IsNodeConverter}" Value="True"> <Setter Property="Focusable" Value="False"/> </DataTrigger> Since it is defined inside TreeView.ItemContainerStyle , the DataContext should be the contained item itself. The Item can either be of type Node or Entry and I want to trigger for all Items that are

Howto observe converted collections?

為{幸葍}努か 提交于 2019-12-11 06:38:54
问题 I bind a collection ObservableCollection<Foo> to a dependency property on my controller, but I run it through an IValueConverter to make it ObservableCollection<object> instead, which is what my controller expect. The conversion works fine - I create an ObservableCollection<object> and fill it with all the Foo's from the original list. This however brings a problem which is that now I'm observing on the collection created in the value converter, and hence doesn't see any of the changes to the

Handling MaxLength via Binding

倾然丶 夕夏残阳落幕 提交于 2019-12-11 06:19:58
问题 I'm trying to handle the MaxLength of a TextBox via Binding. I'm using a Helper Class called 'MaxLengthConverter' (see here http://mariabrinas.com/?p=89). The TextBox looks currently like this: <TextBox MaxLength="{Binding TestValue, Mode=TwoWay, Converter={StaticResource MaxLengthConverter}, ConverterParameter='7'}" Text="{Binding TestValue, Mode=TwoWay}" InputScope="Number" /> And the MaxLengthValueConvert looks like this: public class MaxLengthConverter : IValueConverter { public object

Set Grid Column Width to Bound Perctange

假如想象 提交于 2019-12-11 04:48:15
问题 I want to display a Rectangle with a dynamic Width based on a bound data source. I originally looked into using a Converter , but wasn't able to bind to the converter parameter to get a read dynamic width. My most recent attempt was binding the parent column to the UtilPct property, which is a decimal in my BrokerCredit object. I think this is using the decimal value as an absolute instead of a percentage display. How would I go about doing this? I'd like my Rectangle or the parent column to

Make a slider use an existing IValueConverter

情到浓时终转凉″ 提交于 2019-12-11 01:20:10
问题 I have a slider implementing System.Windows.Controls.Slider: class MySlider : Slider { public MySlider() { Minimum = 1; Maximum = 1000; } } I use it like this: MySlider slider = new MySlider() { Width = 400, Name = "TheSlider"}; It works well, but it is linear. I want to make it non-linear because sensible values are like 1, 2, 10, 1000 (for instance). So I defined a non-linear IValueConverter like this: public class LogScaleConverter : IValueConverter { public object Convert(object value,