How to get additional standalone property from viewmodel or model?

How to get additional standalone property from viewmodel or model?

Old forum URL: forums.lhotka.net/forums/t/10574.aspx


simon posted on Monday, August 01, 2011

I have a textbox in a view with MaskBehavior

<Usercontrol >

<TextBox Grid.Row="1" Grid.Column="1" Margin="3" Height=" 23" Text="{Binding Model.No,UpdateSourceTrigger=PropertyChanged}" inf:MaskBehavior.Mask="{Binding Path= NameMask}" />

</Usercontrol>

code behind:

[Export(typeof(MaterialCompositeView))]

    [PartCreationPolicy(CreationPolicy.NonShared)]

    public partial class MaterialCompositeView : DocumentContent

    {

        public MaterialCompositeView()

        {

            InitializeComponent();

        }

 

        [Import]

        MaterialCompositeViewModel ViewModel

        {

            set

            {

                this.DataContext = value;

            }

        }

    }

in my model, no exist MameMask property.  I add the NameMask Property into my ViewModel.

ViewModel:

[Export(typeof(MaterialCompositeViewModel))]

    [PartCreationPolicy(CreationPolicy.NonShared)]

    public class MaterialCompositeViewModel:ViewModel<Materials>

    {

             Public string NameMask{get;set;}

    }

 

I expect the user can define the mask at runtime.  how can i get the value from the database?

Add a commandbase into the  model to get the value or another solution? pls advise.

Thank you

 

RockfordLhotka replied on Monday, August 01, 2011

simon

I expect the user can define the mask at runtime.  how can i get the value from the database?

Add a commandbase into the  model to get the value or another solution? pls advise.

I typically use simple read only objects to load metadata like that from the database. You'll probably want to use a UOW to load the data and metadata with a single call to the server (especially in Silverlight, where you need both sets of information at the same time, and you need to overcome the async nature of SL).

simon replied on Tuesday, August 02, 2011

I read the UOW of Using Csla.  And how to realize the ViewModel?  below is right?

public class MaterialCompositeViewModel:ViewModel<MaterialComposieViewModel>

{

        Public string NameMask

       {

               get{return NameMaskList..DefultValue;}

        }

        public MaterialCompositeViewModel()

       {

             InitData();

       }

        private void InitData()

        {         

            BeginRefresh("GetMaterialRetriever");

       }

pls advies.

 

Copyright (c) Marimer LLC