valueconverter

WPF Multiple Enum Flags to Converter Parameter?

柔情痞子 提交于 2021-02-19 04:18:38
问题 I have a control which I need visible if an enum value is (A | B | C). I know how to bind the visibility of a control to a SINGLE enum (A) using a converter. How do I go about doing the same for this case? What would go in the parameter? This is the converter I use : public class EnumToVisibilityConverter : IValueConverter { public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) { if ( value == null || parameter == null || !( value

WPF Multiple Enum Flags to Converter Parameter?

感情迁移 提交于 2021-02-19 04:18:37
问题 I have a control which I need visible if an enum value is (A | B | C). I know how to bind the visibility of a control to a SINGLE enum (A) using a converter. How do I go about doing the same for this case? What would go in the parameter? This is the converter I use : public class EnumToVisibilityConverter : IValueConverter { public object Convert( object value, Type targetType, object parameter, System.Globalization.CultureInfo culture ) { if ( value == null || parameter == null || !( value

Convert hex strings to integers

人盡茶涼 提交于 2021-01-28 00:33:59
问题 Visual Basic 2010: Recently in one of my projects I have been tasked with reading several data fields in hex. Each field is three characters long. So this is what I have been doing: 'Read the hex value and convert it to decimal Dim hexVal as string = "38D" Dim intVal as integer = Convert.ToInt32(hexVal, 16) 'The integer result gets multiplied by a scaling factor '(this is set by the manufacturer for each field). Dim fac as single = 200 Dim final as single = intVal * fac Debug.Print (final)

Converter of System.Drawing.Point' to 'System.Windows.Point

巧了我就是萌 提交于 2020-01-05 03:18:15
问题 I am trying to draw few entities in WPF. My collection contains System.Drawing.Rectangle objects, When I try to access the location of those objects in WPF XAML I am getting following error Cannot create default converter to perform 'one-way' conversions between types 'System.Drawing.Point' and 'System.Windows.Point'. Consider using Converter property of Binding I know I have to use some valueconverter. Could you please guide me how to convert System.Drawing.Point' to'System.Windows.Point?

how can I convert wstring to u16string?

≡放荡痞女 提交于 2020-01-01 06:04:07
问题 I want to convert wstring to u16string in C++. I can convert wstring to string, or reverse. But I don't know how convert to u16string . u16string CTextConverter::convertWstring2U16(wstring str) { int iSize; u16string szDest[256] = {}; memset(szDest, 0, 256); iSize = WideCharToMultiByte(CP_UTF8, NULL, str.c_str(), -1, NULL, 0,0,0); WideCharToMultiByte(CP_UTF8, NULL, str.c_str(), -1, szDest, iSize,0,0); u16string s16 = szDest; return s16; } Error in WideCharToMultiByte(CP_UTF8, NULL, str.c_str(

dynamic datatemplate with valueconverter

99封情书 提交于 2019-12-31 04:41:06
问题 I want to show data in a wpftoolkit datagrid where the data is a collection of public class Thing { public string Foo { get; set; } public string Bar { get; set; } public List<Candidate> Candidates { get; set; } } public class Candidate { public string Name { get; set; } public CandidateType CandidateType { get; set; } } public enum CandidateType { Type1, Type2, Type42 } where the number of candidates in Candidates list is configurable at runtime. Desired grid layout looks like this Foo | Bar

WPF binding to another property's binding in a style

不羁的心 提交于 2019-12-30 11:11:50
问题 I'm not sure the best way to ask this question (sorry for the ambiguous question title), but essentially I'd like to set the MaxLength property on a TextBox using a value converter that is passed in a property from the data context, and the property on the passed-in property as the converter parameter. I'd like to do all this in a style, as opposed to on a control-by-control basis. Here's an example of doing this in a non-styled manner: <TextBox Text="{Binding MyPropertyName.TheirPropertyName

Are value converters instantiated per-binding in WPF?

混江龙づ霸主 提交于 2019-12-22 07:39:32
问题 Is a separate WPF value converter object instantiated for each binding that a particular value converter class is used in? I am trying to create a two-way bit-to-boolean value converter. I would like to be able to bind a bool property (such as IsChecked ) to a bit in a value type (like a ushort ). I'm using the converter's parameter arguments to specify the bit. Implementing the ConvertBack() method is easy, but Convert() is little trickier. In Convert() I need to know what the value of the

How to open one view from another view using MVVM in WPF

二次信任 提交于 2019-12-21 20:35:32
问题 I am new to MVVM. And i am not able to get answer of this problem since a long time. I don't know if question is so difficult or i have not explained properly. I have MainWindow.Xaml which contains a textblock and a button to receive the data from textblock and now when i press a button it should open second View called tableView.xaml (I have already created User Control for it/Xaml) . I have two question now (Please note that i am following MVVM while answering)? (1) How to open this View

Hex to int C# with VERY big numbers

邮差的信 提交于 2019-12-21 07:05:27
问题 I have a 256 chars long string that contains a hex value: EC851A69B8ACD843164E10CFF70CF9E86DC2FEE3CF6F374B43C854E3342A2F1AC3E30C741CC41E679DF6D07CE6FA3A66083EC9B8C8BF3AF05D8BDBB0AA6CB3EF8C5BAA2A5E531BA9E28592F99E0FE4F95169A6C63F635D0197E325C5EC76219B907E4EBDCD401FB1986E4E3CA661FF73E7E2B8FD9988E753B7042B2BBCA76679 I want to convert it to a string with numbers like this: