Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1022833
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:31:26+00:00 2026-05-16T11:31:26+00:00

Edit 2 Ok, here is the full example: public class FixedSizeLibraryViewModel : ViewModel {

  • 0

Edit 2
Ok, here is the full example:

public class FixedSizeLibraryViewModel : ViewModel
{
    RawFixedLibrary _library;

    public FixedSizeLibraryViewModel(RawFixedLibrary thisLibrary)
    {
        _library = thisLibrary;
    }

    public string BookOneTitle
    {
        get { return _library.BookOne.Title; }
        set { _library.BookThree.Title = value;
            this.OnPropertyChanged("BookOneTitle");}
    }

    public string BookTwoTitle
    {
        get { return _library.BookThree.Title; }
        set { _library.BookOne.Title = value;
        this.OnPropertyChanged("BookTwoTitle");}
    }

    public string BookThreeTitle
    {
        get { return _library.BookThree.Title; }
        set { _library.BookThree.Title = value;
        this.OnPropertyChanged("BookThreeTitle");}
    }

    public string BookOneText
    {
        get { return _library.BookOne.Text; }
        set { _library.BookThree.Text = value;
        this.OnPropertyChanged("BookOneText");}
    }

    public string BookTwoText
    {
        get { return _library.BookThree.Text; }
        set { _library.BookOne.Text = value;
        this.OnPropertyChanged("BookTwoText");}
    }

    public string BookThreeText
    {
        get { return _library.BookThree.Text; }
        set { _library.BookThree.Text = value;
        this.OnPropertyChanged("BookThreeText");}
    }

    public ????? BookList{
        get{
            if(someCondition)
                //Return Book 1 and book 2 title and text in some sort of list
            else
                //Return Book 2 and book 3 title and text in some sort of list
        }
    }
}

And binding pretty much exactly as before:

    <TabControl ItemsSource="{Binding BookList}">
        <TabControl.ItemTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding BookTitle}"/>
            </DataTemplate> 
        </TabControl.ItemTemplate>
        <TabControl.ContentTemplate>
            <DataTemplate>
                <TextBox Text="{Binding BookContents, Mode=TwoWay}"/>
            </DataTemplate> 
        </TabControl.ContentTemplate>
    </TabControl>

In the full implementation, the book titles and texts are actually very secondary to the rest of the functions of the FixedSizeLibraryViewModel. So the work around I implemented was to simply add one tab for each book, bind the header to the book title and bind the text to the book text, then conditionally hide the tabs based on an additional public property.

This is problematic if we ever need to change the books for obvious reasons. I can bind individually to BookNTitle and BookNText just fine. Changes made to those show up in the original RawFixedLibrary that was passed in. But I can’t find a way to add them to a list and have changes made to them still affect the original RawFixedLibrary.

And ViewModel implments the requirements for the OnPropertyChanged calls.

End edit 2

Edit
Sorry, in reality my situation is a little more complicated than I first let on.
So, in reality the class looks more like this:

    private rawBookData _thisBook;

    public Book(rawBookData rawBook)
    {
        _thisBook = rawBook
        BookTitle = _thisBook.Title;
        BookText = _thisBook.Text;
    }

    public string BookTitle
    {
        get { return _thisBook.Title; }
        set { _thisBook.Title = value; }
    }

    public string BookContent
    {
        get { return _thisBook.Text; }
        set { _thisBook.Text = value; }
    }

EndEdit

I think I have been behind the monitor too long today, I feel like this is really simple and I just cant figure it out.

I have a class with some properties, namely a book title and book contents:

public class Book
{
    private string _boookTitle;
    private string _bookContent;

    public Book(string title, string content)
    {
        _boookTitle = title;
        _bookContent = content;
    }

    public string BookTitle
    {
        get { return _boookTitle; }
        set { _boookTitle = value; }
    }

    public string BookContent
    {
        get { return _bookContent; }
        set { _bookContent = value; }
    }

    public ?????? GetStrings()
    {
        ?????? stringPair;
        //I want this to return the BookTitle and BookContent as some sort of pair
        return stringPair;
    }
}

I need this GetStrings function to pass out something that I can bind to such that I can access and set the BookTitle and BookContents via binding.

I need to ultimately make a list of these objects so I can have a tab per book in a tab control. The idea being that each tab will have the book title, then you can modify the text of the book from within that tab.

I would really like to be able to just pass a list of Books, but due to some other constraints thats not really an easy option here.

So I will have something along the lines of:

    <TabControl ItemsSource="{Binding BookList}">
        <TabControl.ItemTemplate>
            <DataTemplate>
                <TextBlock Text="{Binding BookTitle}"/>
            </DataTemplate> 
        </TabControl.ItemTemplate>
        <TabControl.ContentTemplate>
            <DataTemplate>
                <TextBox Text="{Binding BookContents, Mode=TwoWay}"/>
            </DataTemplate> 
        </TabControl.ContentTemplate>
    </TabControl>
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:31:27+00:00Added an answer on May 16, 2026 at 11:31 am

    Why not just create a class to hold them:

    public BookStuff
    {
         public string BookContents {get; set;}
         public string BookTitle {get; set;}
    }
    

    Then, in your book class

    public BookStuff MyBookStuff {get; set;}
    

    If you need a collection to bind to, I would suggest an ObservableCollection:

    public ObservableCollection<BookStuff> MyListOfBooks {get; set;}
    

    then, set your ItemsSource to MyListOfBooks, and in your ItemTemplate just bind to BookTitle and BookContents

    <TextBox Text="{Binding BookTitle}" ... />
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Edit: You can get the full source here: http://pastebin.com/m26693 Edit again: I added some
When a user links to link it redirects to edit.php - here's an example:
EDIT: Here is the edited control file (control.ascx): <%@ Control Language=C# AutoEventWireup=true CodeFile=Sale.ascx.cs Inherits=Enmasse.Modules.Demo_Enmasse.Sale
EDIT: Here's a create script for the table minus the constraints on the keys
When inserting values into my table what do I edit here? Do I delete
I'm looking to analyze and compare the following `signals': (Edit: better renderings here: oscillations
EDIT - The code looks strange here, so I suggest viewing the files directly
EDIT: See this in action here: http://jsbin.com/emobi/5 -- and that's using mouseenter/mouseleave. I have
Edit: OK I asked the wrong question here. I'm going to be coding a
EDIT Sorry I forgot the most important part here. Each key can have more

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.