Click here to Skip to main content
14,367,980 members

Silverlight / WPF

 
AnswerRe: Add Dictionary in ObsavableCollection Pin
Richard Deeming16-May-16 2:18
mveRichard Deeming16-May-16 2:18 
GeneralRe: Add Dictionary in ObsavableCollection Pin
indian14316-May-16 7:35
memberindian14316-May-16 7:35 
QuestionDatagrid is not updating the values after changing the collection in the ViewModel in WPF Pin
indian14313-May-16 12:02
memberindian14313-May-16 12:02 
AnswerRe: Datagrid is not updating the values after changing the collection in the ViewModel in WPF Pin
Richard Deeming13-May-16 12:16
mveRichard Deeming13-May-16 12:16 
GeneralRe: Datagrid is not updating the values after changing the collection in the ViewModel in WPF Pin
indian14313-May-16 12:44
memberindian14313-May-16 12:44 
GeneralRe: Datagrid is not updating the values after changing the collection in the ViewModel in WPF Pin
indian14313-May-16 22:09
memberindian14313-May-16 22:09 
GeneralRe: Datagrid is not updating the values after changing the collection in the ViewModel in WPF Pin
Pete O'Hanlon14-May-16 4:39
protectorPete O'Hanlon14-May-16 4:39 
QuestionConvert This XAML To C# Pin
Kevin Marois12-May-16 14:45
professionalKevin Marois12-May-16 14:45 
[UPDATE]
I opened Snoop and dragged over my window. It popped up a message about "Snoop has noticed windows running in multiple dispatchers..."

As I was reading it my content appeared. IF I DON'T SNOOOP, IT BEHAVE AS BELOW.
.
.
.
.

I've got this tab control that is defined in XAML. It's an outer TabControl and it's tab items contain their own sub tabs:

I want to convert it to C# so I can load it at runtime.
<TabControl x:Name="mainTabControl"
            ItemsSource="{Binding TabItems}"
            SelectedItem="{Binding SelectedTabItem}"
            BorderBrush="{DynamicResource MainTab.BorderBrush}"
            Style="{DynamicResource MainTab.TabControl.Style}">

<pre>
<userControl:ToolBarTabItem x:Name="ScopeTabItem"
                            DataContext="{Binding ScopeViewModel}"
                            Header="{DynamicResource Maintab.Oscilloscope.Label}"
                            IsTabEnabled="{Binding Path=IsTabAvailable}"
                            TabType="Oscilloscope">

    <TabControl Style="{DynamicResource InnerTabControl.Style}" 
                SelectedIndex="{Binding InnerTabSelectedIndex}"
                ItemContainerStyle="{DynamicResource InnerTab.SelectedTabItem.Style}"<br />
                ItemTemplate="{DynamicResource InnerTab.ViewPort.Header}" 
                ItemsSource="{Binding OscilloscopeViewPortItems}"
                ContentTemplate="{StaticResource TabControlTemplate}"/>

</userControl:ToolBarTabItem>




I added the TabItems collection in the VM and bound it to the outter TabControl(above), then tried the following. The outter tab shows up OK, but the inner
private void LoadTabs()
{
    TabItems = new ObservableCollection<ToolBarTabItem>();

    var scopeTab = AddTab();
    TabItems.Add(scopeTab);
}

private ToolBarTabItem AddTab()
{
    ToolBarTabItem tab = new ToolBarTabItem();

    // Outter tab item
    tab.DataContext = ScopeViewModel;
    tab.Header = GetStringFromResource("Maintab.Oscilloscope.Label");
    tab.TabType = Tabs.Oscilloscope;

    Binding isTabAvailableBinding = new Binding();
    isTabAvailableBinding.Path = new PropertyPath("IsTabAvailable");
    isTabAvailableBinding.Source = ScopeViewModel;
    BindingOperations.SetBinding(tab, ToolBarTabItem.IsTabEnabledProperty, isTabAvailableBinding);

    // Inner tab control
    Style tabControlStyle = Application.Current.FindResource("InnerTabControl.Style") as Style;
    Style itemContainerStyle = Application.Current.FindResource("InnerTab.SelectedTabItem.Style") as Style;
    DataTemplate contentTemplate = Application.Current.FindResource("TabControlTemplate") as DataTemplate;
    DataTemplate itemTemplate = Application.Current.FindResource("InnerTab.ViewPort.Header") as DataTemplate;

    TabControl tabControl = new TabControl();
    tabControl.Style = tabControlStyle;
    tabControl.ItemContainerStyle = itemContainerStyle;
    tabControl.ItemTemplate = itemTemplate;
    tabControl.ContentTemplate = contentTemplate;

    Binding selectedIndexBinding = new Binding();
    selectedIndexBinding.Path = new PropertyPath("InnerTabSelectedIndex");
    selectedIndexBinding.Source = ScopeViewModel;
    BindingOperations.SetBinding(tab, TabControl.SelectedIndexProperty, selectedIndexBinding);

    Binding itemSourceBinding = new Binding();
    itemSourceBinding.Path = new PropertyPath("OscilloscopeViewPortItems");
    itemSourceBinding.Source = ScopeViewModel;
    BindingOperations.SetBinding(tab, TabControl.ItemsSourceProperty, itemSourceBinding);

    tab.Content = tabControl;

    return tab;
}

The resources all seem to be found OK, but I don't see the inner tab. I'm wondering if my bindings are correct. Anyone see anything wrong?

Thanks
If it's not broken, fix it until it is


modified 12-May-16 19:59pm.

QuestionAdd a check box and delete multiple rows from DataGrid in WPF Pin
indian14312-May-16 9:46
memberindian14312-May-16 9:46 
AnswerRe: Add a check box and delete multiple rows from DataGrid in WPF Pin
Mycroft Holmes12-May-16 14:06
memberMycroft Holmes12-May-16 14:06 
GeneralRe: Add a check box and delete multiple rows from DataGrid in WPF Pin
indian14312-May-16 15:12
memberindian14312-May-16 15:12 
QuestionUse Different Paths In Control Template Pin
Kevin Marois11-May-16 14:14
professionalKevin Marois11-May-16 14:14 
AnswerRe: Use Different Paths In Control Template Pin
Gerry Schmitz11-May-16 17:06
mveGerry Schmitz11-May-16 17:06 
QuestionHandle Title Bar Icon Click Pin
Kevin Marois11-May-16 6:56
professionalKevin Marois11-May-16 6:56 
AnswerRe: Handle Title Bar Icon Click Pin
CHill6011-May-16 23:42
protectorCHill6011-May-16 23:42 
AnswerRe: Handle Title Bar Icon Click Pin
Pete O'Hanlon12-May-16 0:50
protectorPete O'Hanlon12-May-16 0:50 
Questionwpf Pin
Member 113037949-May-16 8:39
memberMember 113037949-May-16 8:39 
AnswerRe: wpf Pin
Pete O'Hanlon9-May-16 9:34
protectorPete O'Hanlon9-May-16 9:34 
QuestionRe: wpf Pin
ZurdoDev11-May-16 10:20
professionalZurdoDev11-May-16 10:20 
QuestionWPF Dependency Property Of Type UserControl Pin
Kevin Marois3-May-16 6:32
professionalKevin Marois3-May-16 6:32 
QuestionUse TTF Font From Resources Pin
Kevin Marois28-Apr-16 13:13
professionalKevin Marois28-Apr-16 13:13 
AnswerRe: Use TTF Font From Resources Pin
Richard Deeming29-Apr-16 3:18
mveRichard Deeming29-Apr-16 3:18 
GeneralRe: Use TTF Font From Resources Pin
Kevin Marois29-Apr-16 6:21
professionalKevin Marois29-Apr-16 6:21 
GeneralRe: Use TTF Font From Resources Pin
Kevin Marois29-Apr-16 6:26
professionalKevin Marois29-Apr-16 6:26 
GeneralRe: Use TTF Font From Resources Pin
Kevin Marois29-Apr-16 6:43
professionalKevin Marois29-Apr-16 6:43 

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.