Click here to Skip to main content
15,886,801 members
Home / Discussions / WPF
   

WPF

 
QuestionHow to disable Button in RadGridView. Pin
Sunil G 33-Aug-11 20:00
Sunil G 33-Aug-11 20:00 
AnswerRe: How to disable Button in RadGridView. Pin
Mycroft Holmes4-Aug-11 13:00
professionalMycroft Holmes4-Aug-11 13:00 
QuestionError: Cannot find governing FrameworkElement for target element Pin
John-ph3-Aug-11 19:39
John-ph3-Aug-11 19:39 
QuestionSilverlight Bussines Application user authentication Pin
Eren Can Kaygusuz2-Aug-11 22:06
Eren Can Kaygusuz2-Aug-11 22:06 
AnswerRe: Silverlight Bussines Application user authentication Pin
Mycroft Holmes4-Aug-11 13:03
professionalMycroft Holmes4-Aug-11 13:03 
QuestionSilverlight Bussines Application Domain Service Pin
Eren Can Kaygusuz2-Aug-11 22:00
Eren Can Kaygusuz2-Aug-11 22:00 
QuestionMath in XAML Pin
Mc_Topaz2-Aug-11 3:15
Mc_Topaz2-Aug-11 3:15 
AnswerRe: Math in XAML Pin
dasblinkenlight2-Aug-11 5:53
dasblinkenlight2-Aug-11 5:53 
Short answer is "yes, it is possible".

The long answer is a lot less pleasant: it can't be done for free. Pulling this trick requires work. In fact, it requires a lot of work.

Here are the basic steps:

1. First, you need an expression library capable of evaluating expressions presented to it as strings. You can either build one (making a high-performance evaluation library on top of Linq expressions is surprisingly simple), or adopt one written by someone else (for example, this one: Expression Evaluator[^]).
2. Next, you will need to build a Converter class, which is a small adapter for using your expression evaluator in XAML. One class can implement both IMultiValueConverter.aspx[^] and IValueConverter[^], and expose a string property called "Source".
3. Import the assembly with your adapter into your XAML file by adding a clr-namespace referencing your assembly to the Windows element. xmlns:Converter="clr-namespace:MyNamespace.Converter;assembly=MyConverterAssembly"
4. Add a resource for each expression that you would like evaluated from your XAML:
C#
<Converter:ExpressionValueConverter
    x:Key="CalcTotalWeight"
    Source="(arg1 * 126) + (arg2 * 220)"
/>

5. Use binding or multi-binding to attach your expression to labels and text boxes in your XAML:
XML
<MultiBinding Converter="{StaticResource CalcTotalWeigh}" FallbackValue="0">
    <Binding Path="txtA"/>
    <Binding Path="txtB"/>
</MultiBinding>


I went through this exercise once, and I can tell you that it is not easy. And I started with a well-tested expression library from step 1! But once you put it all together, it looks like a small miracle.
GeneralRe: Math in XAML Pin
Mc_Topaz2-Aug-11 6:22
Mc_Topaz2-Aug-11 6:22 
AnswerRe: Math in XAML Pin
Pete O'Hanlon2-Aug-11 6:08
mvePete O'Hanlon2-Aug-11 6:08 
GeneralRe: Math in XAML Pin
Mc_Topaz2-Aug-11 6:40
Mc_Topaz2-Aug-11 6:40 
GeneralRe: Math in XAML Pin
SledgeHammer012-Aug-11 7:22
SledgeHammer012-Aug-11 7:22 
QuestionClient side validation Pin
yesu prakash1-Aug-11 20:14
yesu prakash1-Aug-11 20:14 
AnswerRe: Client side validation Pin
Mycroft Holmes4-Aug-11 13:07
professionalMycroft Holmes4-Aug-11 13:07 
QuestionDistance Calculate Of A Route Pin
mrhydn1-Aug-11 3:44
mrhydn1-Aug-11 3:44 
QuestionGrid in a combo box [modified] Pin
Lutosław31-Jul-11 2:57
Lutosław31-Jul-11 2:57 
AnswerRe: Grid in a combo box Pin
teejayem31-Jul-11 6:42
teejayem31-Jul-11 6:42 
GeneralRe: Grid in a combo box Pin
Lutosław1-Aug-11 13:14
Lutosław1-Aug-11 13:14 
GeneralRe: Grid in a combo box Pin
SledgeHammer011-Aug-11 14:05
SledgeHammer011-Aug-11 14:05 
GeneralRe: Grid in a combo box [solved] Pin
Lutosław1-Aug-11 22:57
Lutosław1-Aug-11 22:57 
GeneralRe: Grid in a combo box [solved] Pin
SledgeHammer012-Aug-11 7:20
SledgeHammer012-Aug-11 7:20 
GeneralRe: Grid in a combo box [solved] Pin
Lutosław2-Aug-11 8:52
Lutosław2-Aug-11 8:52 
GeneralRe: Grid in a combo box Pin
SledgeHammer011-Aug-11 14:05
SledgeHammer011-Aug-11 14:05 
QuestionBinding: Accept an empty string in enumeration [modified] Pin
Lutosław30-Jul-11 10:24
Lutosław30-Jul-11 10:24 
AnswerRe: Binding: Accept an empty string in enumeration Pin
teejayem30-Jul-11 12:23
teejayem30-Jul-11 12:23 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.