Click here to Skip to main content
15,887,485 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Why do I need a connection string to use an Entity Framework data model? Pin
Mycroft Holmes20-Dec-15 19:23
professionalMycroft Holmes20-Dec-15 19:23 
AnswerRe: Why do I need a connection string to use an Entity Framework data model? Pin
Gerry Schmitz20-Dec-15 18:07
mveGerry Schmitz20-Dec-15 18:07 
AnswerRe: Why do I need a connection string to use an Entity Framework data model? Pin
_T_C_21-Dec-15 7:18
_T_C_21-Dec-15 7:18 
GeneralRe: Why do I need a connection string to use an Entity Framework data model? Pin
Gerry Schmitz23-Dec-15 11:29
mveGerry Schmitz23-Dec-15 11:29 
QuestionHow do I bind based on the value selected in a list box? Pin
_T_C_19-Dec-15 15:45
_T_C_19-Dec-15 15:45 
AnswerRe: How do I bind based on the value selected in a list box? Pin
_T_C_19-Dec-15 17:59
_T_C_19-Dec-15 17:59 
SuggestionRe: How do I bind based on the value selected in a list box? Pin
Richard Deeming4-Jan-16 3:55
mveRichard Deeming4-Jan-16 3:55 
QuestionRequest for help with simple WPF Pin
_T_C_18-Dec-15 11:14
_T_C_18-Dec-15 11:14 
I'm having trouble understanding WPF. I've read many tutorials and reviewed many examples, but I still can't seem to grasp the basics. I'm hoping someone here can give me the push I need to get on track.

A little background: I manage a software product for my company. I'm an engineer, not a programmer, so I program the math stuff and delegate everything else. The product uses WinForms now, but the UI is due for an overhaul and I'm considering a switch to WPF. Thus, I'm trying to learn WPF well enough to plan a possible WinForms to WPF transition.

I've given myself this agenda:
1) As a warm-up exercise, create a WPF version of the About form which uses MVP, MVVM, or some such design pattern to display the application revision number as read from an About Model.
2) Make the About Window show a sample revision number when in design mode.
3) Change the revision number label into a text box that can write to the About Model, just to confirm that I understand two-way binding.
4) Create a WPF version of the Chart form. The Chart Window will be significantly more complicated than the About Window, since it must display a list box of chart names and fields whose values change depending on the list box selection.

I'm working on Item 1 right now. Below, I've pasted the code I've written so far. My question is: How do I change the
<TextBlock Text="v1.0.0.0" />
bit so the About Window shows the contents of its .Model.Version property when the window is displayed?

Here is my startup code:

C#
using System;

namespace TestProject
{
    public static class Startup
    {

        [STAThread]
        public static void Main()
        {
            // Create an instance of the About Model.
            AboutModel aboutModel = new AboutModel { Version = "v1.2.3.4" };

            // Create the About Window.
            AboutWindow aboutWindow = new AboutWindow(aboutModel);

            // Show the About Window
            aboutWindow.ShowDialog();
        }

    }
}


Here is my About Model:

C#
namespace TestProject
{
    public class AboutModel
    {
        public string Version { get; set; }
    }
}


Here is my About Window XAML:

<Window x:Class="TestProject.AboutWindow"
        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"
        Title="About" Height="200" Width="300">
    <StackPanel>
        <TextBlock Text="Product Name " />
        <TextBlock Text="v1.0.0.0" />
    </StackPanel>
</Window>


And here is my About Window C# code:

C#
namespace TestProject
{
    public partial class AboutWindow
    {
        public AboutWindow() : this(new AboutModel()) { }

        public AboutWindow(AboutModel model)
        {
            InitializeComponent();
            _model = model;
        }

        private readonly AboutModel _model;
        public AboutModel Model => _model;
    }
}

AnswerRe: Request for help with simple WPF Pin
Gerry Schmitz18-Dec-15 11:34
mveGerry Schmitz18-Dec-15 11:34 
GeneralRe: Request for help with simple WPF Pin
_T_C_18-Dec-15 11:53
_T_C_18-Dec-15 11:53 
GeneralRe: Request for help with simple WPF Pin
Gerry Schmitz18-Dec-15 12:08
mveGerry Schmitz18-Dec-15 12:08 
GeneralRe: Request for help with simple WPF Pin
_T_C_18-Dec-15 12:42
_T_C_18-Dec-15 12:42 
GeneralRe: Request for help with simple WPF Pin
Gerry Schmitz18-Dec-15 12:57
mveGerry Schmitz18-Dec-15 12:57 
GeneralRe: Request for help with simple WPF Pin
_T_C_18-Dec-15 13:01
_T_C_18-Dec-15 13:01 
GeneralRe: Request for help with simple WPF Pin
Gerry Schmitz18-Dec-15 12:51
mveGerry Schmitz18-Dec-15 12:51 
GeneralRe: Request for help with simple WPF Pin
_T_C_18-Dec-15 12:58
_T_C_18-Dec-15 12:58 
GeneralRe: Request for help with simple WPF Pin
Mycroft Holmes18-Dec-15 13:20
professionalMycroft Holmes18-Dec-15 13:20 
GeneralRe: Request for help with simple WPF Pin
Gerry Schmitz18-Dec-15 13:34
mveGerry Schmitz18-Dec-15 13:34 
AnswerRe: Request for help with simple WPF Pin
Matt T Heffron18-Dec-15 11:58
professionalMatt T Heffron18-Dec-15 11:58 
GeneralRe: Request for help with simple WPF Pin
_T_C_18-Dec-15 12:22
_T_C_18-Dec-15 12:22 
QuestionWPF - Quick Design Question Pin
Kevin Marois18-Dec-15 5:53
professionalKevin Marois18-Dec-15 5:53 
AnswerRe: WPF - Quick Design Question Pin
Joseph M. Morgan18-Dec-15 7:24
Joseph M. Morgan18-Dec-15 7:24 
QuestionUsing DataTemplates Trigger for listbox Pin
Saurabh18cs17-Dec-15 21:35
Saurabh18cs17-Dec-15 21:35 
AnswerRe: Using DataTemplates Trigger for listbox Pin
Joseph M. Morgan18-Dec-15 7:27
Joseph M. Morgan18-Dec-15 7:27 
GeneralRe: Using DataTemplates Trigger for listbox Pin
Saurabh18cs20-Dec-15 21:49
Saurabh18cs20-Dec-15 21:49 

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.