Continuing from using a canvas in tab item

I asked about inserting a canvas into a tab item and ws given an answer which helped sort the problem , howvere i have hit another problem , the code is
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
namespace WPFDynamicTab
    /// <summary>
    /// Interaction logic for MainWindow.xaml
    /// </summary>
    public partial class MainWindow : Window
        private List<TabItem> _tabItems;
        private TabItem _tabAdd;
        private Canvas canvas1;
        public MainWindow()
           try
                InitializeComponent();
                // initialize tabItem array
                _tabItems = new List<TabItem>();
                // add a tabItem with + in header
                _tabAdd = new TabItem();
                 canvas1= new Canvas();
                _tabAdd.Header = "+";
                _tabAdd.MouseLeftButtonUp += _tabAdd_MouseLeftButtonUp;
                _tabItems.Add(_tabAdd);
                this.AddTabItem();   // add first tab
                // bind tab control
                tabDynamic.DataContext = _tabItems;
                tabDynamic.SelectedIndex = 0;
            catch (Exception ex)
                MessageBox.Show(ex.Message);
        private TabItem AddTabItem()
            int count = _tabItems.Count;
            // create new tab item
            TabItem tab = new TabItem();
            tab.Header = string.Format("Tab {0}", count);
            tab.Name = string.Format("tab{0}", count);
            tab.HeaderTemplate = tabDynamic.FindResource("TabHeader") as DataTemplate;
            // add controls to tab item, this case I added just a canvas
            Canvas canvas = new Canvas();
            canvas.Name = "canvas";
            Canvas canvas1 = new Canvas();
            canvas1.Name = "canvas1";
            // defining the background color of "canvas"
            switch (count)
                case 0:
                    canvas.Background = Brushes.Green;
                    break;
                case 1:
                    canvas.Background = Brushes.Red;
                    break;
                case 2:
                    canvas.Background = Brushes.Blue;
                    break;
                case 3:
                    canvas.Background = Brushes.Yellow;
                    break;
                case 4:
                    canvas.Background = Brushes.Brown;
                    break;
                case 5:
                    canvas.Background = Brushes.Orange;
                    break;
                case 6:
                    canvas.Background = Brushes.Olive;
                    break;
                default:
                    break;
            // Canvas_Paint defines the background color of  "canvas1"
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
        //    tab.Content = canvas;     // ORIGINAL (commented out) to populate tab.Content with canvas
            Canvas_Paint();
            tab.Content = canvas1;      //  NEW to populate tab.Content with canvas
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
            // insert tab item right before the last (+) tab item
            _tabItems.Insert(count - 1, tab);
            return tab;
        private void _tabAdd_MouseLeftButtonUp(object sender, MouseButtonEventArgs e)
            TabItem newTab = this.AddTabItem();
            // clear tab control binding
            tabDynamic.DataContext = null;
            // bind tab control
            tabDynamic.DataContext = _tabItems;
            tabDynamic.SelectedItem = newTab;
        private void Canvas_Paint()
            int count = _tabItems.Count;
            switch (count)
                case 0:
                    canvas1.Background = Brushes.Green;
                    break;
                case 1:
                    canvas1.Background = Brushes.Red;
                    break;
                case 2:
                    canvas1.Background = Brushes.Blue;
                    break;
                case 3:
                    canvas1.Background = Brushes.Yellow;
                    break;
                case 4:
                    canvas1.Background = Brushes.Brown;
                    break;
                case 5:
                    canvas1.Background = Brushes.Orange;
                    break;
                case 6:
                    canvas1.Background = Brushes.Olive;
                    break;
                default:
                    break;
        private void tabDynamic_SelectionChanged(object sender, SelectionChangedEventArgs e)
and the xml is
<Window x:Class="WPFDynamicTab.MainWindow"
        xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        Title="Dynamic Tab" Height="300" Width="527" WindowStartupLocation="CenterScreen">
    <Grid>
        <TabControl Name="tabDynamic" ItemsSource="{Binding}" SelectionChanged="tabDynamic_SelectionChanged">
            <TabControl.Resources>
                <DataTemplate x:Key="TabHeader" DataType="TabItem">
                    <DockPanel>
                        <TextBlock Text="{Binding RelativeSource={RelativeSource AncestorType=TabItem }, Path=Header}" />
                    </DockPanel>
                </DataTemplate>
            </TabControl.Resources>
        </TabControl>
    </Grid>
</Window>
The problem is when i use the Canvas "canvas" with the canvas pouplated within the method  all is ok  , however using "canvas1" where canvas1 is populated in Canvas_Paint 
"canvas1" has null entries. How can I set the background colour in the tab using Canvas_Paint. Can the canvs be put in the XML? I hve simplified the problem from a much more complicated one in order to highlight the problem
steve

>>I asked about inserting a canvas into a tab item and ws given an answer which helped sort the problem , howvere i have hit another problem , the code is
Please close your previous threads by marking helpful posts as answer before starting a new one. And please only ask one question per thread.
>>How can I set the background colour in the tab using Canvas_Paint?
You never set the Background of the canvas1 that you create in the AddTabItem() and use as the Content of the TabItem. Just remove this line from this method:
Canvas canvas1 = new Canvas();
...and you will see the background:
private TabItem AddTabItem()
int count = _tabItems.Count;
// create new tab item
TabItem tab = new TabItem();
tab.Header = string.Format("Tab {0}", count);
tab.Name = string.Format("tab{0}", count);
tab.HeaderTemplate = tabDynamic.FindResource("TabHeader") as DataTemplate;
// add controls to tab item, this case I added just a canvas
Canvas canvas = new Canvas();
canvas.Name = "canvas";
canvas1.Name = "canvas1";
// defining the background color of "canvas"
switch (count)
case 0:
canvas.Background = Brushes.Green;
break;
case 1:
canvas.Background = Brushes.Red;
break;
case 2:
canvas.Background = Brushes.Blue;
break;
case 3:
canvas.Background = Brushes.Yellow;
break;
case 4:
canvas.Background = Brushes.Brown;
break;
case 5:
canvas.Background = Brushes.Orange;
break;
case 6:
canvas.Background = Brushes.Olive;
break;
default:
break;
// Canvas_Paint defines the background color of "canvas1"
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
//tab.Content = canvas; // ORIGINAL (commented out) to populate tab.Content with canvas
Canvas_Paint();
tab.Content = canvas1; // NEW to populate tab.Content with canvas
// XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX
// insert tab item right before the last (+) tab item
_tabItems.Insert(count - 1, tab);
return tab;
Another approach bay be to pass the Canvas element to the painted to the Canvas_Paint() method by reference instead of using a class-level field:
Canvas_Paint(ref canvas1);
tab.Content = canvas1;
private void Canvas_Paint(ref Canvas canvas1)
int count = _tabItems.Count;
switch (count)
case 0:
canvas1.Background = Brushes.Green;
break;
case 1:
canvas1.Background = Brushes.Red;
break;
case 2:
canvas1.Background = Brushes.Blue;
break;
case 3:
canvas1.Background = Brushes.Yellow;
break;
case 4:
canvas1.Background = Brushes.Brown;
break;
case 5:
canvas1.Background = Brushes.Orange;
break;
case 6:
canvas1.Background = Brushes.Olive;
break;
default:
break;
Please remember to close your threads by marking helpful posts as answer and please start a new thread if you have a new question.

Similar Messages

  • How to use stack canvas in tab canvas in oracle forms

    hi all,
    how to use stack canvas in tab canvas in oracle forms. please if any one help out in this.

    Hi
    u can simply create a button in ur tab canvas in this button pls write the following as an example...
    SHOW_VIEW('STACKED_CANVAS');
    GO_ITEM ('SAL'); -- Pls note this item should be navigable and visible in ur stacked canvas form
    HIDE_VIEW('TAB_CANVAS');In order to return back to ur tab_canvas pls create a button in this button pls write the following...
    HIDE_VIEW('STACKED_CANVAS');
    SHOW_VIEW('TAB_CANVAS');
    GO_BLOCK('EMP');
    GO_ITEM ('EMPNO'); -- Pls note this item should be navigable and visible in ur stacked canvas form
    Hope this helps...
    Regards,
    Abdetu...

  • STO from unrestricted to E stock from TAB item in Sales Order?

    Hi all,
    We have the situation where we are shipping stock intra-company via the STO Process. The requirements are being driven of a TAB item on the Sales Order, and the purchase req is being generated automatically, and being converted to STO > Delivery > Shipped then received at requesting plant.
    If we leave the Dependent Requirements Indicator on MRP4 in Material Master to blank the stock is shipped from the shipping plant as Sales Order stock and received into the requesting plant as Sales Order stock. If we change the Dependent Requirements Indicator on MRP4 in material Master to '2' then it trys to ship the stock as unrestricted, and the theory is that is should be received as Sales Order stock.
    Shipping as Unrestricted and receiving as Sales Order stock is exactly the scenario we are trying to achieve. 
    We initially ran into an issue with error message M7146. OSS Note 305582 describes this situation, and says we need to change the consumption posting on Account Assignment Catgegory M to be 'E - Accounting via Sales Order'.
    So we changed this, and now when we try and create the Sales Order we get an error message kd051 Maintain a Settlement Profile. We are told by our Finance people that we cannot use the Sales Order as a cost collector as it impacts the PA reporting, so I am wondering if anyone has any suggestions as to how we can resolve this issue.
    Many Thanks.

    Dear all,
    can u update me with the depot to depot process   ( like  there some  20 qty in 1300 depot   i wanted to transfer the  20 qty to 1200 depot)
    what is the process should be followed   
    i am still  not getting the right way  
    please guide me    my process i am following is  :
    supplying plant
    Create a STO PO from receiving plant  T-code ME21n
    Create delivery with ref to STO PO   T-code VL10b
    Post goods issue     T-code VL02n
    Create Depot Excise invoice with  Reference to delivery document T-code J1IJ
    Create pro-forma invoice   T-code VF01
    Receving plant
    Goods receipt   (With out excise capture selection)  T-code MIGO
    Capture excise invoice at depot  (Enter challan qty and Excise baseAmount)  T-code J1IG
    Please guide me on this as it is critical

  • Is it okay to delete SymSecondaryLaunch from my Log in at startup Items in System Preferences?  I no longer use any Norton products.

    Is it okay to delete SymSecondaryLaunch from my Log in at startup Items in System Preferences?  I no longer use any Norton products.  I have no clue what SymSecondaryLaunch does but it appears to be related to Symantec.

    You are not required to have any login items so yes, you can safely remove. However some applications will continue to add it's self back until completely uninstalled. You might have to download an install to get an uninstaller.
    http://www.symantec.com/business/support/index?page=content&id=TECH103489
    It's possible you have other old software that is running parts. Download EtreCheck and paste results here for help troubleshooting.
    http://www.etresoft.com/etrecheck

  • I used to open many tabs in the same page and i move from one to other by mouse but since3 two days the tabs open in the same page normaly but i can't move from one to other when i clik with mouse on any tab it don't open/ do u have any solve for this?

    i used to open many tabs in the same page and i move from one to other by mouse but since3 two days the tabs open in the same page normaly but i can't move from one to other when i clik with mouse on any tab it don't open/ do u have any solve for this

    Start Firefox in <u>[[Safe Mode|Safe Mode]]</u> to check if one of the extensions (Firefox/Tools > Add-ons > Extensions) or if hardware acceleration is causing the problem (switch to the DEFAULT theme: Firefox/Tools > Add-ons > Appearance).
    *Do not click the Reset button on the Safe mode start window or otherwise make changes.
    *https://support.mozilla.org/kb/Safe+Mode
    *https://support.mozilla.org/kb/Troubleshooting+extensions+and+themes

  • I recently bought an iphone 4s from people who are not in the know and restore my iphone .. Now do not be in use for not having ID and password ... Owner apple owner just gave me a serial number how do I want to continue to use this ... Their telephone he

    I recently bought an iphone 4s from people who are not in the know
    and restore my iphone .. Now do not be in use for not having ID and password ... Owner apple owner just gave me a serial number how do I want to continue to use this ... Their telephone help me: (

    I am having same problem . i can not use the phone. my Carrier ROGERS checked the phone its not stolen or lost phone but after restoring always ask for apple ID of previous owner and seller is not responding to any mails or phone if some one can help me out than it will be great.
    thank you

  • How to  show additional items in the same window using stacked canvas

    How to show additional items in the same window using stacked canvas.
    My content canvas has 14 items, and I have to include more.
    I want to know how I can use a stacked canvas to show these additional items in the same window, so that I can scroll through horzontally , as if all the items are on one canvas.

    Well, I intially navigate into my content canvas. At this stage the stacked canvas is not visible, then how should I navigate to an item on the stacked canvas to make it visible?

  • Dear Apple,  I have an iPhone 4 32GB (black), i bought from softbank, japan. Now, I have recently finished a graduate and i'll comeback home in Laos. But i can't continue to use my iphone. Could you please help me to unlock my phone so I can use it with o

    Dear Apple,
    I have an iPhone 4 32GB (black), i bought from softbank, japan. Now, I have recently finished a graduate and i'll comeback home in Laos. But i can't continue to use my iphone.
    Could you please help me to unlock my phone so I can use it with other carrier Sims. I would appreciate it.
    Please let me know if you could help me out. Thanks again.
    <Edited by Host>

    Like ckuan said, Apple does not unlock iPhone; your carrier does, provided that the carrier offers this service.
    Unfortunately, SoftBank does not offer authorized unlocking of iPhone.
    Your best option is to sell this phone and buy another iPhone from the carrier of your choice or better buy a factory unlocked iPhone so you would be able to use it with any compatible GSM carrier around the world.

  • How do I remove my phone number from my iphone so that i can continue to use it like an ipod touch and use imessages with email/apple ID?

    How do i remove my phone number from my iphone 4s so that i can continue to use it as an ipod touch and use imessages with email/apple ID?

    This article explains what to do:
    http://support.apple.com/kb/HT5661

  • Efficient way to use TAB item

    Most ofter, we are using TAB item cat for our order, one so map to one po, it is the simplest scenario, but sometime, we have inventory, we would like to use the in ventory first, then issue po to purchase item. I should said, I want to item check the available first, then the remain item will issue PO for purchase. Thanks!

    Hello Friend,
    In that case assign a approval process and workflow to your order types.So when ever an order is saved it will be locked for further activities and unless and until it is released manually by the concerned officer then only it will trigger the future actions. Through workflow the person responsible will get the notification for approval.

  • Using finder icon to navigate continuously from folder to folder

    A consultant set our old G5 (OS 10.4.11) so you could click and hold on the finder icon to open the HD and navigate continuously from folder thru subfolder, thru subfolder, thru subfolder, etc (like dragging and dropping a file – except without the file). Wanted to set my Intel Mac to do the same.  Messed up the old computer trying to figure out what the consultant had done (I think he altered sidebar options in finder preferences).  Now, when I click and hold on the finder a little window opens with the name of the computer, and below it says "hide."  (On my Intel Mac it just says "hide")  Wife's gonna kill me!  How do I restore old G4?  Can I get my G5 to open folders the way the G4 did, by just holding down on the finder icon?

    Thanks Kappy,
    I do get the "pop" feature when I drag my HD icon to the dock, next to the trash, but when using the "pop" feature I have to click on each individual subfolder I need to open to get to my destination.  The way our G4 worked required only a single click on the Finder icon.  By clicking on it, and then keeping the mouse held down, the HD would open, showing all its folders.  Dragging the mouse arrow to any single folder opened its window to reveal its subfolders.  Dragging to one of those folders opened its window, allowing you to drag to the next subfolder and the next - down the entire hierarchy to reach any sought-for file, without having to do any more clicking.  Do you know a way to restore that feature to the G4?   Any way to get it to work on my Intel Mac?
    Thanks in advance.

  • Using a canvas for item renderer

    I have an array collection of objects. The class has a
    function getDisplayObject which returns a canvas with all of the
    components I need in it. I'd like to use that canvas directly as a
    custom renderer for a combo box. How can I set the returned canvas
    as the item renderer? I've made custom renderers, but not with a
    canvas itself. I think I need to call getDisplayObject inside of
    the item renderer for each object, but am not sure how. Thanks.
    (Below is what I've tried, but this only adds the first one out of
    an array of 5... hmm...)

    Hi Usernnnnnn,
    I know an applciation that's using such kind of tree.
    It's published in the Oracle magazine, may 2006. And is named: Build a menu framework. You can dowload the application:
    http://oracle.com/technology/oramag/oracle/06-may/o36apex.zip
    The menu looks like you have described.
    Leo

  • Move Field from Stacked Canvas to Tab Canvas

    Forms R2 10.1.2.0.2. Adding tab canvas to an existing form and want to retrofit a tab canvas into the form. When I move an existing field via the property sheet by changing Canvas and Tab page to Page, the field does not show. I can create a new field on the tab canvas with no problem. Is there a trick here that I am missing?

    I figured it out. You have to reset the X & Y position with an offset of the 0,0 position. The Tab Canvas has it own Grid separate from the Main Canvas, which starts at 0,0. I should have seen it before creating this post.

  • Am trying to install CS6 on my new MacBook Pro. Downloaded installer from web. Ran installer, got a dialog asking me to "Please close these applications to continue:..." There were two items on the list: Safari

    "Please close these applications to continue:..." There were two items on the list: Safari & SafariNotificati (sic). I closed Safari, no problem. But could not find SafariNotifications.
    What I have done so far:
    Opened "Force Quit" and the only applications listed as open now are "Finder" and "Adobe Application Manager".
    Pressed "Continue" on the "Please close..." dialoge
    Still asks me to close SafariNotificati
    Opened Safari
    Opened Safari Preferences > Notifications Tab
    There are no notifications listed. The list is blank.
    Closed Safari again.
    Checked Force Quit again (once again the only applications listed are "Finder" and "Adobe Application Manager"
    Once again if I try to move on with the install by clicking on the "Continue" button Adobe asks me to close SafariNotificati
    What should I do now?
    My System Info
    MackBook Pro (Retina, 15-inch, Mid 2014)
    OS X Yosemite
    Ver 10.10.1

    use your activity monitor to find running processes.

  • Is it possible to prevent users from using the ''Purge'' option from the ''Recover deleted items'' in Office 365?

    Hi,
    After speaking with a Microsoft engineer over the phone, I've been told that there is no way to prevent users to go to their OWA and manually Purge specific items from the ''Recover deleted items''. The Microsoft tech told us to place the desired mailboxes
    on a litigation-hold and that all data will be recoverable... but only from the time you place the mailbox onto Litigation-Hold and previous items, which doesn't take effect for new-coming emails. 
    1- From what I understand, any new items coming in the mailbox after the Litigation-Hold is put in place will still be ''purgeable'', right?
    2- Is there a way (PowerShell, Security group, etc.) that can prevent a user from using the Purge option?
    We are very surprised that there is absolutely no thread that talks about this issue, which in our opinion, is a major legal and security flaw from Office 365. This is a main concern for us to actually go with Office365. For instance, this means that at
    any given time, if a user exchanges emails with a competitor, they can manually purge emails sent and receive as soon as it is sent/received, even after Litigation-Hold is in place.
    Thank you for your reply and let us know if you have more questions.
    Normand Bessette, IT support technician, Newad Media

    Thank you for the reply.
    Is there still a way to prevent users from using the Purge option, like with a Powershell script to disable Purge?

Maybe you are looking for

  • Getting error  connection timed out while invoking webservice from bpel.

    Hi, I am trying to call a secure webservice developed in .Net having extension .svc from the bpel service and in response i am getting error com.oracle.bpel.client.BPELFault: faultName: {{http://schemas.oracle.com/bpel/extension}remoteFault} messageT

  • My external hard drive won't work on my new mac

    ive just got my mac book pro and was wanting to transfer all my music from my Windows Laptop, i have a Toshiba Stor.e Canvio 500gb which i have put allof my music onto i plugged it into my macbook via usb and nothing seems to happen the mac doesnt sh

  • Firewire 1394a cable to connect to thunderbolt

    I have the thunderbolt to firewire adapter for my MacBook Pro Retina but I don't know what cable to cable part number to buy to connect my older HD/Printer/Scaanners that all use the Firewire 1394 - 6 pin connector cables. I'd like to buy the correct

  • HELP!!!! VERSION CHANGE

    I finished my work at home using flash 8...only to find out that the school version is 6. I worked really hard on this, and is there ANY way to open in version 6. PS: If i cant get the perfect work loaded, at least 80% of it!!! I just want most or at

  • I cannot sign on internet using 3.6 after update?

    My internet has crashed 3 times in the last 2 days. Firefox says it has updates to load, and postpones the starting of my home page. Then the page comes up saying there is a problem loading. I then have to re-load Mozilla Firefox from the executable