Click here to Skip to main content
15,912,329 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: populate datagrid Pin
V.30-Dec-11 1:15
professionalV.30-Dec-11 1:15 
GeneralRe: populate datagrid Pin
arkiboys30-Dec-11 1:21
arkiboys30-Dec-11 1:21 
GeneralRe: populate datagrid Pin
V.30-Dec-11 1:43
professionalV.30-Dec-11 1:43 
GeneralRe: populate datagrid Pin
V.30-Dec-11 1:46
professionalV.30-Dec-11 1:46 
GeneralRe: populate datagrid Pin
arkiboys30-Dec-11 10:32
arkiboys30-Dec-11 10:32 
GeneralRe: populate datagrid Pin
V.30-Dec-11 22:37
professionalV.30-Dec-11 22:37 
GeneralRe: populate datagrid Pin
arkiboys2-Jan-12 11:49
arkiboys2-Jan-12 11:49 
QuestionLoad Usercontrols in MVVM Pin
jogisarge29-Dec-11 10:59
jogisarge29-Dec-11 10:59 
Hi @all,

i know that there a many articles about my problem but i cant find a solution.
I am new in WPF - MVVM and i try to understand the MVVM-Logic.
So i made a little project to understand that.
For my later apps i want to load UserControls dynamicly to my Window.

In my StartView i have a Binding to the StartViewModel.
(The Binding is in the APP.xaml)
C#
StartView app = new StartView();
StartViewModel context = new StartViewModel();


the StartView
HTML
<Window x:Class="test.Views.StartView"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        xmlns:views="clr-namespace:test.ViewModel"
        Title="Window1" Height="300" Width="516">
    <Grid>
        <Menu IsMainMenu="True" Margin="0,0,404,239">
            <MenuItem Header="_Einstellungen">
                <MenuItem Header="Server" />
            </MenuItem>
        </Menu>
        <ContentControl Content="{Binding LoadedControl}" Margin="0,28,0,128" />
    </Grid>
</Window>


the StartViewModel

C#
namespace test.ViewModel
{
    public class StartViewModel : ViewModelBase
    {
        #region Fields
        private UCStastistikViewModel _loadedControl;
        #endregion

        public StartViewModel()
        {
            LoadedControl = new UCStastistikViewModel();
        }

        #region Properties / Commands
        public UCStastistikViewModel LoadedControl
        {
            get { return _loadedControl; }
            set
            {
                if (value == _loadedControl)
                    return;

                _loadedControl = value;
                OnPropertyChanged("LoadedControl");
            }
        }
        #endregion

        #region Methods
       
        #endregion
    }
}


UCStatistikView

HTML
<UserControl x:Class="test.Views.UCStatistik"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
             xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
             xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006" 
             xmlns:d="http://schemas.microsoft.com/expression/blend/2008" 
             xmlns:vm="clr-namespace:test.ViewModel"
             mc:Ignorable="d" 
             d:DesignHeight="188" d:DesignWidth="508">
    <UserControl.DataContext>
        <vm:UCStastistikViewModel />
    </UserControl.DataContext>
    <Grid Background="red">       
    </Grid>
</UserControl>


UCStatistikViewModel

C#
namespace test.ViewModel
{
    public class UCStastistikViewModel : ViewModelBase
    {
        #region Fields
        #endregion

        public UCStastistikViewModel()
        {
        }

        #region Properties / Commands
        #endregion

        #region Methods
        #endregion
    }
}


Now i want to load my UCStatistikView in the ContentControl of my StartView.

But in the Startview only the Path test.UCStatistikViewModel is shown instead of the whole UC

Can anybody give me some Ideas to Fix it ?



Bye jogi
AnswerRe: Load Usercontrols in MVVM Pin
Pete O'Hanlon29-Dec-11 11:52
mvePete O'Hanlon29-Dec-11 11:52 
Questiondata binding and resource file Pin
zedray28-Dec-11 0:29
zedray28-Dec-11 0:29 
QuestionPayment gateway in Silverlight Pin
saroja24127-Dec-11 1:47
saroja24127-Dec-11 1:47 
AnswerRe: Payment gateway in Silverlight Pin
ThatsAlok3-Jan-12 20:28
ThatsAlok3-Jan-12 20:28 
QuestionWPF does not run on an other machine Pin
Turhan Coskun25-Dec-11 10:34
professionalTurhan Coskun25-Dec-11 10:34 
AnswerRe: WPF does not run on an other machine Pin
SledgeHammer0125-Dec-11 12:54
SledgeHammer0125-Dec-11 12:54 
GeneralRe: WPF does not run on an other machine Pin
Turhan Coskun26-Dec-11 1:16
professionalTurhan Coskun26-Dec-11 1:16 
GeneralRe: WPF does not run on an other machine Pin
SledgeHammer0126-Dec-11 7:39
SledgeHammer0126-Dec-11 7:39 
AnswerRe: WPF does not run on an other machine Pin
Turhan Coskun28-Dec-11 3:38
professionalTurhan Coskun28-Dec-11 3:38 
QuestionBinding a SolidColorBrush resource of Theme Pin
Prasoon Chaudhary22-Dec-11 23:22
Prasoon Chaudhary22-Dec-11 23:22 
QuestionSilverlight Navigation menu Pin
arkiboys22-Dec-11 21:25
arkiboys22-Dec-11 21:25 
AnswerRe: Silverlight Navigation menu Pin
Abhinav S27-Dec-11 21:21
Abhinav S27-Dec-11 21:21 
GeneralRe: Silverlight Navigation menu Pin
arkiboys27-Dec-11 23:07
arkiboys27-Dec-11 23:07 
GeneralRe: Silverlight Navigation menu Pin
Abhinav S27-Dec-11 23:16
Abhinav S27-Dec-11 23:16 
Question[silverlight]How to customerize the readonly for each datagridcell Pin
Loveisasea21-Dec-11 21:43
Loveisasea21-Dec-11 21:43 
QuestionThe authentication header received from the server was 'Negotiate,NTLM' Pin
indian14321-Dec-11 6:30
indian14321-Dec-11 6:30 
AnswerRe: The authentication header received from the server was 'Negotiate,NTLM' Pin
thatraja21-Dec-11 6:58
professionalthatraja21-Dec-11 6:58 

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.