Click here to Skip to main content
15,914,066 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Service Model Pin
Mycroft Holmes8-Aug-11 1:31
professionalMycroft Holmes8-Aug-11 1:31 
GeneralRe: Service Model Pin
Simon Bang Terkildsen8-Aug-11 1:46
Simon Bang Terkildsen8-Aug-11 1:46 
QuestionSilverlight and SmartCards Pin
#realJSOP6-Aug-11 1:59
professional#realJSOP6-Aug-11 1:59 
AnswerRe: Silverlight and SmartCards Pin
Mycroft Holmes6-Aug-11 2:47
professionalMycroft Holmes6-Aug-11 2:47 
QuestionBuild TreeViewItem dynamically [modified] Pin
McCombi5-Aug-11 1:19
McCombi5-Aug-11 1:19 
AnswerRe: Build TreeViewItem dynamically Pin
SledgeHammer015-Aug-11 4:57
SledgeHammer015-Aug-11 4:57 
GeneralRe: Build TreeViewItem dynamically Pin
McCombi7-Aug-11 22:29
McCombi7-Aug-11 22:29 
AnswerRe: Build TreeViewItem dynamically Pin
Mycroft Holmes5-Aug-11 18:09
professionalMycroft Holmes5-Aug-11 18:09 
AnswerRe: Build TreeViewItem dynamically Pin
McCombi7-Aug-11 22:43
McCombi7-Aug-11 22:43 
AnswerRe: Build TreeViewItem dynamically Pin
McCombi31-Aug-11 2:39
McCombi31-Aug-11 2:39 
QuestionWindows Phone 7, buttons and events when moving your finger Pin
Sir TK4-Aug-11 22:50
Sir TK4-Aug-11 22:50 
Questiondatabinding in wpf Pin
GLolita4-Aug-11 15:57
GLolita4-Aug-11 15:57 
QuestionOveriding context menu default style except for textbox contextmenu Pin
John-ph3-Aug-11 20:05
John-ph3-Aug-11 20:05 
AnswerRe: Overiding context menu default style except for textbox contextmenu Pin
SledgeHammer014-Aug-11 8:50
SledgeHammer014-Aug-11 8:50 
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 
I would like to do some simple math in my WPF application with as much XAML code as possible and with as little C# code as possible. I have looked at various examples how to do this on diffrent web pages, but they are either to complex or don't show all details or lacks code or is just a bad example.

Please run my XAML code, just copy and paste it:
XAML
<Window x:Class="WpfApplication1.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="MainWindow" Height="350" Width="525">
    
    <Window.Resources>
        <Style x:Key="Alignment">
            <Setter Property="Control.HorizontalAlignment" Value="Left"></Setter>
            <Setter Property="Control.VerticalAlignment" Value="Top"></Setter>
        </Style>
        <Style x:Key="GroupBoxStyle" BasedOn="{StaticResource Alignment}">
            <Setter Property="Control.BorderBrush" Value="Black"></Setter>
            <Setter Property="Control.BorderThickness" Value="2"></Setter>
            <Setter Property="Control.FontSize" Value="15"></Setter>
        </Style>
        <Style x:Key="Header">
            <Setter Property="Control.FontSize" Value="15"></Setter>
            <Setter Property="Control.FontWeight" Value="Bold"></Setter>
            <Setter Property="Control.Height" Value="30"></Setter>
        </Style>
    </Window.Resources>

    <Grid>
        <GroupBox Header="Product schedule" Margin="0,0,0,0" Style="{StaticResource GroupBoxStyle}"  Width="Auto" Height="Auto">
            <Grid>
                <Grid.RowDefinitions>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                    <RowDefinition Height="Auto"/>
                </Grid.RowDefinitions>

                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                    <ColumnDefinition Width="Auto"/>
                </Grid.ColumnDefinitions>

                <!-- Header -->
                <Label Content="Product" Grid.Row="0" Grid.Column="0" Style="{StaticResource Header}"></Label>
                <Label Content="Weight (g)" Grid.Row="0" Grid.Column="1" Style="{StaticResource Header}"></Label>
                <Label Content="Numbers" Grid.Row="0" Grid.Column="2" Style="{StaticResource Header}"></Label>
                <Label Content="Total weight (g)" Grid.Row="0" Grid.Column="3" Style="{StaticResource Header}"></Label>

                <!-- Product A -->
                <Label Content="A" Grid.Row="1" Grid.Column="0"></Label>
                <Label Content="126" Grid.Row="1" Grid.Column="1"></Label>
                <TextBox Name="txtA" Grid.Row="1" Grid.Column="2"></TextBox>
                <Label Name="lblATotalWeightGram" Grid.Row="1" Grid.Column="3"></Label>

                <!-- Product B -->
                <Label Content="B" Grid.Row="2" Grid.Column="0"></Label>
                <Label Content="220" Grid.Row="2" Grid.Column="1"></Label>
                <TextBox Name="txtB" Grid.Row="2" Grid.Column="2"></TextBox>
                <Label Name="lblBTotalWeightram" Grid.Row="2" Grid.Column="3"></Label>

                <!-- Total -->
                <Label Content="Total" Grid.Row="3" Grid.Column="0"></Label>
                <Label Name="lblPiiGABTotal" Grid.Row="3" Grid.Column="2"></Label>
                <Label Name="lblPiiGABTotalWeightGram" Grid.Row="3" Grid.Column="3"></Label>
                <Label Name="lblPiiGABTotalWeightKiloGram" Grid.Row="3" Grid.Column="4"></Label>
            </Grid>
        </GroupBox>
    </Grid>
</Window>


Notice I have two Textboxes to specify numbers of product A and product B.
I would like to calculate the following:

1) Total Weight in g for each product: A * 126 and B * 220
2) Calculate total amounth of products: A + B
3) Calculate total weight of all products: (A * 126) + (B * 220)

This should be done if I change any values in the TextBoxes.

Any help would be nice!
AnswerRe: Math in XAML Pin
dasblinkenlight2-Aug-11 5:53
dasblinkenlight2-Aug-11 5:53 
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 

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.