This is a migrated thread and some comments may be shown as answers.

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

0 Answers 65 Views
General Discussions
This is a migrated thread and some comments may be shown as answers.
David
Top achievements
Rank 1
David asked on 07 Feb 2017, 05:54 PM

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}" 
              …     />

No answers yet. Maybe you can help?

Tags
General Discussions
Asked by
David
Top achievements
Rank 1
Share this question
or