valueconverter

How do you apply a ValueConverter to a convention-based Caliburn.Micro binding?

£可爱£侵袭症+ 提交于 2019-12-08 16:55:05
问题 How do you apply a ValueConverter to a convention-based Caliburn.Micro binding? or do you need to use the {Binding} syntax? I know I could do this <TextBlock Text="{Binding Foo, Converter=fooToBarConverter}" /> but how do I apply that custom converter if I am using Caliburn.Micro's convention over configuration, like <TextBlock x:Name="Foo" /> Thanks, 回答1: You need to replace the ConventionManager.ApplyValueConverter func. By default it only does athe bool => Visibility conversion. Also, you

When to use value converters in a mvvm application?

帅比萌擦擦* 提交于 2019-12-08 04:14:04
问题 If one is implementing a WPF application using the MVVM design pattern, is there any situation in which to use value converters? It seems to me that value converters do exactly the same what the view model does too, that is preparing data for the view. So, are there some good uses for value converters? Best Regards Oliver Hanappi 回答1: Value converters are handy to translate logical states into visual states that are only relevant for the UI. A BooleanToVisibility converter, for example, has

UWP ValueConverter with DependencyProperty

家住魔仙堡 提交于 2019-12-08 03:14:58
问题 I have a UWP project, and I am trying to get a binding on my ValueConverter . It is based on this guide. I have created a DependencyProperty on the ValueConverter , but it is always null , instead of an element of type Vehicle . There is my code: MainPage.xaml <Page x:Class="Project.Pages.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http:

UWP ValueConverter with DependencyProperty

三世轮回 提交于 2019-12-06 16:45:15
I have a UWP project, and I am trying to get a binding on my ValueConverter . It is based on this guide . I have created a DependencyProperty on the ValueConverter , but it is always null , instead of an element of type Vehicle . There is my code: MainPage.xaml <Page x:Class="Project.Pages.MainPage" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:d="http://schemas.microsoft.com/expression/blend/2008" xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" mc:Ignorable="d" xmlns:conv="using:Project

Should your ViewModel expose XAML elements as properties or not?

不羁岁月 提交于 2019-12-06 07:31:54
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 they are used in the MVVM Template demo , see the "Messenger Sample" after unpacking it) in that they

Are value converters instantiated per-binding in WPF?

断了今生、忘了曾经 提交于 2019-12-05 09:59:07
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 entire ushort is so I can toggle just the single bit I am interested in. I was thinking of just using a

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

可紊 提交于 2019-12-04 14:51:30
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 "tableView.xaml" from button click by closing the current opened MainWindow.xaml form (this button click

How to convert any Object to String?

╄→гoц情女王★ 提交于 2019-12-04 10:11:36
问题 Here is my code: for (String toEmail : toEmailList) { Log.i("GMail","toEmail: "+toEmail); emailMessage.addRecipient(Message.RecipientType.TO, new InternetAddress(toEmail)); } Please give me some suggestion about this. 回答1: To convert any object to string there are several methods in Java String convertedToString = String.valueOf(Object); //method 1 String convertedToString = "" + Object; //method 2 String convertedToString = Object.toString(); //method 3 I would prefer the first and third

Convert decimal value to top 10

前提是你 提交于 2019-12-04 06:14:22
问题 I recived some great help earlier today but it was more difficult when I should implement it in my query than I thought. My real query includes several left joins. I want to add two columns, T3MOutput and T1GOutput that shows a 10-1 ranking based on T3M and T1G columns. The gratest value there should get 10 in the ranking scale and the lowest (negative value) should get 1. Notice ! A horse race can be less than 15 horses at start. After the ten best values recived 10-1 the rest should also

how can I convert wstring to u16string?

大城市里の小女人 提交于 2019-12-03 16:19:42
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(), -1, szDest, iSize,0,0);'s szDest . Cause of u16string can't use with LPSTR . How can I fix this code