How might I use namespaces to split the backing fields for multiple .xaml files, but one WPF application into multiple classes?

1 posts, 0 answers
  1. David
    David avatar
    1 posts
    Member since:
    Feb 2017

    Posted 07 Feb 2017 Link to this post

    I have an app with scores of .xaml files, and dozens of xaml fields that are in turn bound to dozens of backing properties.  Right now, this is all a flat namespace.  Each xaml represents a “UserControl” (one UserControl per xaml). 

    A problem is that every backing property (dozens) lives in a single object.  I want to control specific backing properties using specific classes.  For instance, I might want the Admin page xaml fields to all be bound to an Admin object while the Status area fields might be bound to a Status object. 

    How can I do this?    Right now, I only have the option of binding every field in the xaml's to a single name space.

    For instance, I want to say something like:

    File: UC_AdminView.xaml:  --- bind the fields here to the AdminView backing object
    <UserControl x:Class="Gui.View.UC_AdminView"
    … >
    <StackPanel x:Name="AppInfo">
                        <Label Content="{Binding AdminView.AppName}" 
                  …     />



    - and - 

    File: UC_StatusArea.xaml:  --- bind the fields here to the StatusArea backing object
    <UserControl x:Class="Gui.View.UC_StatusArea"

    … >
    <StackPanel x:Name="StatusStuff">
                        <Label Content="{Binding StatusArea.Name}" 
                  …     />

Back to Top