valueconverter

Unable to find enum type for static reference in WPF

人盡茶涼 提交于 2019-12-17 20:43:38
问题 I'm trying to bind an enum to a radio button in WPF (Inspired by this answer), but I have trouble finding the enum type for the converter parameter: The enum is defined in the following way namespace Application.Models { public class Enums { public enum MySelections { one, two ,three }; public MySelections CurrentSelection; ... } } I am trying to bind now the checkbox like this (The data context is assumed to be correct and the value converter implemented:) <Window x:Class="Application

How can I display array elements in a WPF DataGrid?

放肆的年华 提交于 2019-12-17 19:34:57
问题 I'm trying to display a series of rows in a WPF DataGrid where each row contains an array of booleans (the number of which is the same for all rows, it's not a jagged 2D array) that I want to display as individual columns, eg. Name | Day 1 | Day 2 | Day 3 | Day 4 | Day 5 | Day 6 | ----------------------------------------------------------------- Bring out Trash | X | | X | | | X | Pay Bills | | | | | X | | Commit Suicide | | | | | | X | Currently, I'm using this class for my DataGrid rows:

Convert binary string to binary or decimal value

爱⌒轻易说出口 提交于 2019-12-17 06:38:27
问题 Is there any function to convert binary string into binary or decimal value? If I have a binary string 000101 , what should I do to convert it into 5 ? 回答1: Here is what you can try: binStr <- "00000001001100110000010110110111" # 20121015 (binNum <- 00000001001100110000010110110111) # 20121015 [1] 1.0011e+24 binVec <- c(1,0,1,0,0,0,1,1,0,0,0,0,0,0,1,0,0,0,0,0,0,1) # 2670721 shortBin <- 10011010010 # 1234 BinToDec <- function(x) sum(2^(which(rev(unlist(strsplit(as.character(x), "")) == 1))-1))

How to convert YYYDD to YYYY-MM_DD format using java

烈酒焚心 提交于 2019-12-13 20:18:35
问题 I am getting date in the format of YYYDD , and I want to convert it in YYYY-MM-DD , I tried several ways but no luck, any one has solution please suggest. after searching on Google I got the below link, which has function to convert above data format but it is asking for two parameters one is input date string and second is number of days to add. any suggestion translateDateStr 回答1: Using SimpleDateFormat: SimpleDateFormat format1 = new SimpleDateFormat("yyDDD"); SimpleDateFormat format2 =

DataGrid refresh issue

蓝咒 提交于 2019-12-12 03:09:57
问题 I have a Silverlight 4 DataGrid which has its ItemsSource bound to an ObservableCollection . When i modify an element of my ObservableCollection the modified element is correctly displayed inside my grid except the element of one column . This columns differs from the others in the way it is a TemplateColumn and it's using a ValueConverter . The Template for the column consists of a simple stackPanel that includes a Path control and a Label. And the Label is bound to some Source object with

Value Converters - Access Convert() variables in ConvertBack() method?

久未见 提交于 2019-12-12 01:47:24
问题 I have a converter which has a couple of input variables (an object and a TextBox) and then returns the TextBox.Text String property. The problem I'm running into is in the ConvertBack() Method of my converter. I have no way of linking any updates back to the object since all I get is a String (the Text of the Textbox). Is there some way I can access some (if not all) the Convert() variables? Or at least know which textbox is calling ConvertBack() ? Here is my ItemsControl Code: <ItemsControl

ValueConverter with properties [duplicate]

懵懂的女人 提交于 2019-12-11 06:36:29
问题 This question already has answers here : Converter with Dependency Properties (2 answers) Closed last year . Extending the following question: Defining a Property in a IValueConverter class My question is: In the xaml file, TrueValue is set to a single value: <CheckBox IsChecked="{Binding item, Converter={converter:ValueConverterWithProperties TrueValue=5}}"></CheckBox> Is it possible to bind a property in a ValueConverter to some kind of List? How would the binding expression look like? 回答1:

Efficiency of (multiple) MultiDataTrigger vs. Converter

倾然丶 夕夏残阳落幕 提交于 2019-12-10 14:45:15
问题 I'm currently analyzing some XAML that uses style that make extensive use of MultiDataTriggers (8-10 multi data triggers per style, with 4-6 conditions per trigger). When looking at this I'm considering whether it would be more efficient to use a converter (or multi value converter), especially as MultiDataTriggers cannot be debugged. Can anyone authoritatively state how MultiDataTriggers are compiled? I understand that the Conditions are ANDed together, is this compiled in such a way that

Converting Milliseconds to Days, hours, minutes and seconds

馋奶兔 提交于 2019-12-10 13:09:10
问题 i have a bigint field in Microsoft SQL Server 2008R2 filled with ticks (A single tick represents one hundred nanoseconds or one ten-millionth of a second. There are 10,000 ticks in a millisecond.) http://msdn.microsoft.com/en-us/library/system.datetime.ticks.aspx and i need to convert the sum of all records to Days:Hours:Minutes:Seconds:Milliseconds. it works for a single record: SELECT CONVERT(TIME, DATEADD(ms, duration/10000, 0)) FROM tblMediaFileProperties WHERE FileId = '6C0A849D-95B4

Should your ViewModel expose XAML elements as properties or not?

戏子无情 提交于 2019-12-10 11:24:37
问题 Over at the StackOverflow question How can WPF Converters be used in an MVVM pattern? I've learned that Value Converters should not be used in the MVVM pattern since the functionality of a Value Converter should be handled by the ViewModel itself . This makes sense. But I remember reading that you should not expose XAML elements to the View , but instead expose only collections of data which the View then binds and displays using DataTemplates. However, converters seem quite powerful (e.g. as