Click here to Skip to main content
15,908,931 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: OpenDialog Pin
Pete O'Hanlon24-Nov-11 0:33
mvePete O'Hanlon24-Nov-11 0:33 
QuestionView states Pin
Geysser23-Nov-11 4:00
Geysser23-Nov-11 4:00 
AnswerRe: View states Pin
Wayne Gaylard23-Nov-11 4:48
professionalWayne Gaylard23-Nov-11 4:48 
GeneralRe: View states Pin
Geysser23-Nov-11 4:56
Geysser23-Nov-11 4:56 
GeneralRe: View states Pin
Wayne Gaylard23-Nov-11 4:59
professionalWayne Gaylard23-Nov-11 4:59 
QuestionHow to activate the tab in tab control by select the business object Pin
Loveisasea23-Nov-11 1:05
Loveisasea23-Nov-11 1:05 
AnswerRe: How to activate the tab in tab control by select the business object Pin
John-ph23-Nov-11 1:34
John-ph23-Nov-11 1:34 
AnswerRe: How to activate the tab in tab control by select the business object Pin
Wayne Gaylard23-Nov-11 2:00
professionalWayne Gaylard23-Nov-11 2:00 
You can bind a Tabcontrol to a collection of Business objects. I tried this as an excercise.

My Models
C#
public class Factory
    {
        public string Name { get; set; }
    }
    public class Factories : ObservableCollection<Factory>
    {
        public Factories()
        {
            for (int i = 0; i < 5; i++)
            {
                Factory factory = new Factory() { Name = "Factory " + i.ToString() };
                this.Add(factory);
            }
        }
    }




My code behind:
C#
public Factories AllFactories { get; set; }
        Factory currentFactory;
        public Factory CurrentFactory 
        {
            get
            {
                return currentFactory;
            }
            set
            {
                currentFactory = value;
                NotifyPropertyChanged("CurrentFactory");
            }
        }

        public MainWindow()
        {
            InitializeComponent();
            AllFactories = new Factories();
            this.DataContext = this;
        }

        public event PropertyChangedEventHandler PropertyChanged;
        public void NotifyPropertyChanged(String info)
        {
            PropertyChangedEventHandler handler = PropertyChanged;

            if (handler != null)
            {
                handler(this, new PropertyChangedEventArgs(info));
            }
        }


and

My XAML
XML
<Grid>
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition />
        </Grid.RowDefinitions>
        <Grid.Resources>
            <DataTemplate DataType="{x:Type local:Factory}">
                <TextBlock  Text="{Binding Path=Name}"/>
            </DataTemplate>
        </Grid.Resources>
        <ComboBox ItemsSource="{Binding Path=AllFactories}" SelectedItem="{Binding Path=CurrentFactory, Mode=TwoWay}"/>
        <TabControl Name="tcMain" Grid.Row="1" DataContext="{Binding}" ItemsSource="{Binding Path=AllFactories}"
                    IsSynchronizedWithCurrentItem="True" SelectedItem="{Binding Path=CurrentFactory, Mode=TwoWay}">
            <TabControl.ItemTemplate>
                <DataTemplate>
                    <DockPanel >
                        <Label Content="{Binding Path=Name}" Margin="3"/>
                    </DockPanel>
                </DataTemplate>
            </TabControl.ItemTemplate>
        </TabControl>
    </Grid>



I bound a Combo to AllFactories as well as the TabControl to check whether if I select a factory it will change on the tab control, and it all works peachy. I am sure if you go through this, you will see where you are going wrong.

Hope this helps
When I was a coder, we worked on algorithms. Today, we memorize APIs for countless libraries — those libraries have the algorithms - Eric Allman

GeneralRe: How to activate the tab in tab control by select the business object Pin
Loveisasea24-Nov-11 1:04
Loveisasea24-Nov-11 1:04 
GeneralRe: How to activate the tab in tab control by select the business object Pin
Wayne Gaylard24-Nov-11 2:02
professionalWayne Gaylard24-Nov-11 2:02 
QuestionMessageBox - when application loads a WPF theme DLL Pin
Prasoon Chaudhary23-Nov-11 0:42
Prasoon Chaudhary23-Nov-11 0:42 
AnswerRe: MessageBox - when application loads a WPF theme DLL Pin
John-ph23-Nov-11 1:54
John-ph23-Nov-11 1:54 
GeneralRe: MessageBox - when application loads a WPF theme DLL Pin
Prasoon Chaudhary23-Nov-11 4:59
Prasoon Chaudhary23-Nov-11 4:59 
AnswerRe: MessageBox - when application loads a WPF theme DLL Pin
Pete O'Hanlon23-Nov-11 2:39
mvePete O'Hanlon23-Nov-11 2:39 
GeneralRe: MessageBox - when application loads a WPF theme DLL Pin
Prasoon Chaudhary23-Nov-11 4:55
Prasoon Chaudhary23-Nov-11 4:55 
QuestionHow to merge cells/rows in flowdocument table? Pin
John-ph23-Nov-11 0:25
John-ph23-Nov-11 0:25 
QuestionEvents Pin
columbos1492721-Nov-11 21:13
columbos1492721-Nov-11 21:13 
AnswerRe: Events Pin
Albert Holguin22-Nov-11 5:09
professionalAlbert Holguin22-Nov-11 5:09 
QuestionHow to get a listboxitem's visual position in a listbox panel Pin
Loveisasea21-Nov-11 17:13
Loveisasea21-Nov-11 17:13 
AnswerRe: How to get a listboxitem's visual position in a listbox panel Pin
Abhinav S21-Nov-11 19:27
Abhinav S21-Nov-11 19:27 
QuestionHow to Customize SDK:Tab Control Pin
Mayur Bheda20-Nov-11 22:09
Mayur Bheda20-Nov-11 22:09 
QuestionRe: How to Customize SDK:Tab Control Pin
Mark Salsbery21-Nov-11 5:02
Mark Salsbery21-Nov-11 5:02 
QuestionRetrieving icons associated with installed Printers for use in C# and WPF Pin
Alisaunder20-Nov-11 12:55
Alisaunder20-Nov-11 12:55 
AnswerRe: Retrieving icons associated with installed Printers for use in C# and WPF Pin
SledgeHammer0120-Nov-11 17:32
SledgeHammer0120-Nov-11 17:32 
GeneralRe: Retrieving icons associated with installed Printers for use in C# and WPF Pin
Alisaunder20-Nov-11 18:24
Alisaunder20-Nov-11 18:24 

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.