Click here to Skip to main content
15,886,026 members
Home / Discussions / WPF
   

WPF

 
AnswerRe: Add Dictionary in ObsavableCollection Pin
Richard Deeming16-May-16 1:18
mveRichard Deeming16-May-16 1:18 
GeneralRe: Add Dictionary in ObsavableCollection Pin
indian14316-May-16 6:35
indian14316-May-16 6:35 
QuestionDatagrid is not updating the values after changing the collection in the ViewModel in WPF Pin
indian14313-May-16 11:02
indian14313-May-16 11:02 
AnswerRe: Datagrid is not updating the values after changing the collection in the ViewModel in WPF Pin
Richard Deeming13-May-16 11:16
mveRichard Deeming13-May-16 11:16 
GeneralRe: Datagrid is not updating the values after changing the collection in the ViewModel in WPF Pin
indian14313-May-16 11:44
indian14313-May-16 11:44 
GeneralRe: Datagrid is not updating the values after changing the collection in the ViewModel in WPF Pin
indian14313-May-16 21:09
indian14313-May-16 21:09 
GeneralRe: Datagrid is not updating the values after changing the collection in the ViewModel in WPF Pin
Pete O'Hanlon14-May-16 3:39
mvePete O'Hanlon14-May-16 3:39 
QuestionConvert This XAML To C# Pin
Kevin Marois12-May-16 13:45
professionalKevin Marois12-May-16 13: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 8:46
indian14312-May-16 8:46 
AnswerRe: Add a check box and delete multiple rows from DataGrid in WPF Pin
Mycroft Holmes12-May-16 13:06
professionalMycroft Holmes12-May-16 13:06 
GeneralRe: Add a check box and delete multiple rows from DataGrid in WPF Pin
indian14312-May-16 14:12
indian14312-May-16 14:12 
QuestionUse Different Paths In Control Template Pin
Kevin Marois11-May-16 13:14
professionalKevin Marois11-May-16 13:14 
AnswerRe: Use Different Paths In Control Template Pin
Gerry Schmitz11-May-16 16:06
mveGerry Schmitz11-May-16 16:06 
QuestionHandle Title Bar Icon Click Pin
Kevin Marois11-May-16 5:56
professionalKevin Marois11-May-16 5:56 
AnswerRe: Handle Title Bar Icon Click Pin
CHill6011-May-16 22:42
mveCHill6011-May-16 22:42 
AnswerRe: Handle Title Bar Icon Click Pin
Pete O'Hanlon11-May-16 23:50
mvePete O'Hanlon11-May-16 23:50 
Questionwpf Pin
Member 113037949-May-16 7:39
Member 113037949-May-16 7:39 
AnswerRe: wpf Pin
Pete O'Hanlon9-May-16 8:34
mvePete O'Hanlon9-May-16 8:34 
QuestionRe: wpf Pin
ZurdoDev11-May-16 9:20
professionalZurdoDev11-May-16 9:20 
QuestionWPF Dependency Property Of Type UserControl Pin
Kevin Marois3-May-16 5:32
professionalKevin Marois3-May-16 5:32 
QuestionUse TTF Font From Resources Pin
Kevin Marois28-Apr-16 12:13
professionalKevin Marois28-Apr-16 12:13 
AnswerRe: Use TTF Font From Resources Pin
Richard Deeming29-Apr-16 2:18
mveRichard Deeming29-Apr-16 2:18 
GeneralRe: Use TTF Font From Resources Pin
Kevin Marois29-Apr-16 5:21
professionalKevin Marois29-Apr-16 5:21 
GeneralRe: Use TTF Font From Resources Pin
Kevin Marois29-Apr-16 5:26
professionalKevin Marois29-Apr-16 5:26 
GeneralRe: Use TTF Font From Resources Pin
Kevin Marois29-Apr-16 5:43
professionalKevin Marois29-Apr-16 5: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.