Why is the template binding not refreshing?

I made this itemtemplate for a combobox:
<DataTemplate x:Key="EO_CategoryItemTemplate">
<Grid>
<Line
Stroke="Gray"
StrokeThickness="1"
VerticalAlignment="Center"
X1="0"
X2="{Binding ActualWidth, ElementName=cat1}"
Visibility="{Binding Active, Converter={StaticResource EO_BooleanToVisibility}, ConverterParameter=Reverse}"
/>
<TextBlock
x:Name="cat1"
Text="{Binding Name}"
ToolTipService.ToolTip="{Binding InactiveTooltip}"
VerticalAlignment="Center"
HorizontalAlignment="Left"
/>
</Grid>
</DataTemplate>
The problem is the line.  It seems to only get set in the combobox's main text ONCE.  On the first SelectedItem change.  After that, its length is still that of the first item.
In the popup listbox, it is fine.  Each item has a different length line.
Is there something I can do so that the combobox text has a line through the actual characters?

I spent some time looking at this and I'm afraid I have nothing but bad news.
My markup
<Grid x:Name="LayoutRoot" Background="White">
<Grid.Resources>
<DataTemplate x:Key="TestTemplate">
<Border HorizontalAlignment="Left">
<Grid VerticalAlignment="Center">
<TextBlock x:Name="NameTb"
Text="{Binding Name}" Foreground="Gray" />
<Line StrokeThickness="1"
VerticalAlignment="Center"
X1="1"
X2="{Binding ActualWidth, RelativeSource={RelativeSource AncestorType=Border}}"
Stroke="Black" />
</Grid>
</Border>
</DataTemplate>
</Grid.Resources>
<ComboBox ItemsSource="{Binding Items}"
ItemTemplate="{StaticResource TestTemplate}" Height="30" Width="200" SelectionChanged="ComboBox_SelectionChanged"
/>
Code behind
private T FindControlByType<T>(DependencyObject container, string name) where T : DependencyObject
T foundControl = null;
//for each child object in the container
for (int i = 0; i < VisualTreeHelper.GetChildrenCount(container); i++)
//is the object of the type we are looking for?
if (VisualTreeHelper.GetChild(container, i) is T && (VisualTreeHelper.GetChild(container, i).GetValue(FrameworkElement.NameProperty).Equals(name) || name == null))
foundControl = (T)VisualTreeHelper.GetChild(container, i);
break;
//if not, does it have children?
else if (VisualTreeHelper.GetChildrenCount(VisualTreeHelper.GetChild(container, i)) > 0)
//recursively look at its children
foundControl = FindControlByType<T>(VisualTreeHelper.GetChild(container, i), name);
if (foundControl != null)
break;
return foundControl;
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
ComboBox cbo = sender as ComboBox;
if (cbo.SelectedItem != null)
int ix = cbo.Items.IndexOf(cbo.SelectedItem);
ComboBoxItem cboI = cbo.ItemContainerGenerator.ContainerFromIndex(ix) as ComboBoxItem;
Line ln = FindControlByType<Line>(cboI, null);
if (ln != null)
ln.Visibility = Visibility.Collapsed;
// ln.Visibility = Visibility.Visible;
// Debug.WriteLine(ln.X2.ToString());
//BindingExpression be = ln.GetBindingExpression(Line.X2Property);
//be.UpdateSource();
As you can see, I'm obtaining a reference to the line object.
When I  then:
explicitly updatesource on the binding, no effect.
debug writeline X2 - gives correct length, matching the item but not what you see in the selection.
I also tried invalidating and forcing arrange and measure and all that lark on the combo.
No joy.
This one is the weirdest.
If you set visibility to collapsed on the line you still see the "wrong" line visible in the selection part of the combo.
Despite the fact that the item in the combo has  no line.
Once that thing gets a line, it's keeping hold of it.
My conclusion is that this is a bug.
I would guess your chances of getting it fixed for Silverlight 4 are vanishingly slim though.
A work round I can think of, would be to maybe draw the text and image onto a bitmap.
Present those in the combo.
If your line visibility is actually dynamic that's not going to work.
Hope that helps.
Technet articles: Uneventful MVVM;
All my Technet Articles

Similar Messages

  • Why is the template not being used when dynamic page called ?

    Hi,
    I have created a dynamic page and assigned a template to it. When I call the dynamic page using the 'show' procedure from a form, I do not see the template.
    Why is the template not being used ? How can I get the template working when I call the dynamic page ?
    I even tried to show the page from the dynamic page's manage components tab and there is same problem. Template is not being used.
    thanks,
    Mainak

    You can alter the generated package body to include the following function in the header and footer sections.
    Header:
    PORTAL.wwv_headings.show_header(
    p_template => 'PUBLIC.TEMPLATE_3',
    p_heading => 'Dynamic Page',
    p_help_link => 'PORTAL_DEMO.EXAMPLE_DYNAMIC_PAGE.help',
    p_about_link => 'PORTAL_DEMO.EXAMPLE_DYNAMIC_PAGE.about');
    Footer:
    PORTAL.wwv_headings.show_footer(
    p_template => 'PUBLIC.TEMPLATE_3',
    p_help_link => 'PORTAL_DEMO.EXAMPLE_DYNAMIC_PAGE.help');
    where
    <PORTAL_DEMO> indicates application schema
    <PORTAL> indicates the name of the portal (normally this will be portal30 by default).

  • Why are the templates not in english? how do i change it

    why are the templates not in english? how do i change it

    dfields77 wrote:
    why are the templates not in english?
    To learn about this standard practice for template text, google "lorem ipsum".

  • Why the templates are not responsive

    why the templates are not responsive in FormsCentral, and why there's not a preset address field, telephone and a calculation for billing. why i can't change my pdf form to an html form ofor my website?

    CeraG - It will help to answer if you supply your system version, pages version and if you lately have done anything to the computer (installing, uninstalling etc)
    I think you have forgotten to do a Software update or it could also be a font problem but more info from you is needed!

  • The Finder is not refreshing the icon thumbnail after copying

    The Finder is not refreshing the icon thumbnail after copying.
    I tried copying a couple of foders from the internal HD to a USB drive and the resulting icons kept an empty progress...
    WHY????

    Hello,
    It looks like possibly a Permissions problem... the X above the folder.
    In Finder do a Get Info on that drive, or the folders on that drive that you're trying to copy to.
    Úgy néz ki, mint esetleg egy Engedélyek probléma ... X felett a mappát.
    A kereső nem egy Get Info a meghajtón, vagy a mappákat a meghajtón, hogy akarsz másolni.

  • Why does the iPad Mini not have music play count?

    I bought an iPad Mini and also have a macbook. I had listened to various music on my iPad Mini the other day, however when I connected the iPad Mini to the Macbook and iTunes via the lightning connector to sync, it synced the ratings I gave the songs I listened to on the mini, but no play count, as if I had not listened to anything. I hope there is something I can do about this as I often look at my play count!!

    Katrina UK
    It should work work but these kind of bugs pop up between updates, both hardware and software. Try closing all apps in the recently used list on the iPad. Double tap the Home button, tap and hold one of the icons at the bottom till they wiggle then tap the to close them. Tap the Home button to get back to the Home screen then hold the sleep button till you see the slide to power off message. Once it has powered down completely hold the Sleep button till the Apple icon appears.
    tomyiiii
    Re: Why does the iPad Mini not have music play count? 
    Nov 18, 2012 11:34 AM (in response to Katrina UK)
    Does it even really matter...?
    Many people including myself rely on playcounts to control smart playlist to manage large libraries. Smart playlists can be created to show your most or least played tracks and used more or less as your favorites or other uses. Along with playcounts the date is transferred so to keep a fresh list of music on my smaller iPods a smart playlist set to songs not played in the last month keeps some fresh tunes on it.
    Playcounts are also used to manage Podcasts in iTunes to delete older episode. Bookmarks, which can also be effected by this, can mess up audiobooks, movies and podcast playback between different devices. So yes, it does matter.

  • Why does the sync button not work in itunes when my ipod touch is connected

    why does the sync button not work in itunes when my ipod touch is connected?

    It's working for me in Acrobat XI:
    I'd try logging into Acrobat.com from your browser, and log in with your Adobe ID. There may be a problem there:
    workspaces.acrobat.com

  • Why is the "plug in" not working every time i try to stream?

    Why is the "plug in" not working every time i try to stream?

    If you own "Sausage Fattner" you'll find a update in your email that solves this problem.

  • Why is the scroll function not working after accessing the voice feature in settings?

    Why is the scroll function not working after accessing the voice feature in settings?

    For some prerecorded audio files the Transpose slider will not work reliably. I found no clear pattern, when it does and when not.
    If all fails, create a loop from the audio file. Select the region in the track and use the command "File: Add region to Loop library".
    Set the current key and tempo, name the loop, and save the loop.
    Now add it from the loop browser to a new track and delete your old track. The search field in the Loop browser will help you to find the loop quickly.
    You will be able to transpose the sample as described above, like a regular loop.
    For example - a audio file turned into a loop and transposed:

  • TS2972 why is the import button not showing at the button right hand corner of iTunes?

    why is the import button not showing at the bottom right hand corner of my ITunes page.  I am trying to transfer files from my home share library onto a new computers library.

    See if it isn't hidden under the View menu. iTunes- Turning on iTunes menus in Windows 8 and 7.

  • Used a template to create form. when I run it from a page, the template is not shown

    I have created a form based on a template. When I run it from the applications page I can see the template. I then added it as an application component item with a folder in a content area. I have then published this folder as a portlet in a page. When I the form from the portlet within that page, it opens up in a new window but there is no template.
    How do I get the template to show when I run it from the portlet ?

    It is true that the template is not shown when the form is run as a portlet. But, with a small amount of coding in the additional pl/sql section, you can display the template.
    Steps :-
    1> Edit the form and go to the additional pl/sql section.
    2> Put the following code in the "...before displaying the page" area
    declare
    l_mid integer;
    l_title varchar2(32767);
    l_template varchar2(200);
    begin
    l_mid := p_session.get_module().id;
    l_title := p_session.get_module().title;
    l_template := p_session.get_module().template;
    <portal_schema>.wwv_headings.show_header
    p_template => l_template,
    p_heading => l_title,
    p_help_link => <portal_schema>.wwctx_api.get_proc_path('wwa_app_module.help')
    || '?p_module_id='||l_mid
    end;
    3> Put the following code in the "...after displaying the page" area
    declare
    l_template varchar2(200);
    begin
    l_template := p_session.get_module().template;
    <portal_schema>.wwv_headings.show_footer
    p_template => l_template
    end;
    Note: replace <portal_schema> with appropriate your portal schema .

  • Why does the apps store not accept my ID and password, it works fine to log into this forum and it works for the apple store, but not to log in to buy apps, it just keeps telling me that the id or password is wrong, and I know it isn't

    Why does the apps store not accept my ID and password, it works fine to log into this forum and it works for the apple store, but not to log in to buy apps, it just keeps telling me that the id or password is wrong, and I know it isn't

    I Just signed in to find the answer to this too.  I started having the same trouble today.

  • Why do the youtube clips not expand properly when I double click on the page

    why do the youtube clips not expand properly when I double click on the page

    The exclamation mark is telling you that iPhoto has broken the file path/link to the original file. Assuming you're using iPhoto 9 or later Apply the two fixes below in order as needed:
    Fix #1
    1 - launch iPhoto with the Command+Option keys held down and rebuild the library.
    2 - run Option #4 to rebuild the database.
    Fix #2
    Using iPhoto Library Manager  to Rebuild Your iPhoto Library
    1 - download iPhoto Library Manager and launch.
    2 - click on the Add Library button and select the library you want to add in the selection window..
    3 - Now that the library is listed in the left hand pane of iPLM, click on your library and go to the Library ➙ Rebuild Library menu option.
    4 - In the next  window name the new library and select the location you want it to be placed.
    5 - Click on the Create button.
    Note: This creates a new library based on the LIbraryData.xml file in the library and will recover Events, Albums, keywords, titles and comments but not books, calendars or slideshows. The original library will be left untouched for further attempts at fixing the problem or in case the rebuilt library is not satisfactory.
    OT

  • My time capsule is full and when I attempt to back up, I only receive a preparing back up message and the earliest and most recent back up dates remain the same.  Why are the oldest backups not being deleted to make room for the newest backups?

    My time capsule is full and when I attempt to back up, I only receive a preparing back up message and the earliest and most recent back up dates remain the same.  Why are the oldest backups not being deleted to make room for the newest backups?

    linda mariefromharper woods wrote:
    My time capsule is full and when I attempt to back up, I only receive a preparing back up message and the earliest and most recent back up dates remain the same.  Why are the oldest backups not being deleted to make room for the newest backups?
    It may be in the process of making room.  What version of OSX are you on?    (That process can be excruciatingly slow on Leopard or Snow Leopard backups over a network;  Lion has improved it greatly.)
    A clue may be lurking in your logs.  Use the widget in #A1 of  Time Machine - Troubleshooting to display the backup messages from your logs.   That should help you figure out what's going on.  If in doubt, copy and post them here (but if the same ones repeat over and over, drop most of the duplicates).
    If you can, connect via Ethernet; it will be 2-3 times faster.

  • [X-Fi] Why do the "small things" not wo

    Creative has designed and produced a great soundcard, I think many people will agree with this point. Of course, there are some small problems, but that's ok with such a high technology product (Vista Support, Crackling Problem).
    But:
    Why is the X-Fi not capable of Dolby Digital (respecti'vely DTS) Li've Encoding and you have to buy an external DTS encoder, so you get D/A -> A/D -> A/D converting.
    Why is there no mode-switcher integrated in the driver and I have to use third party tools, which cause problems sometimes?
    Why is there no Linux/Unix-support respecti'vely a Open Source-driver?
    I'm sure there will be some more "small things" people want to get realised. Especially the not existing DTS/DD-Encoding should be done without great technical problems, and also without licence-related problems, otherwise the external DTS encoder wouldn't have been realised that fast. I think Creative just wants to earn fast & easy money.

    You are right... specially the last line in youre post. But i agree with everything you said.
    I think Creative just wants to earn fast & easy money.
    But there is no answer, and dont expect one from CL. As they are sitting home and counting the easy money, and laughing their rich asses off!! "LOL the suckers....Hope we can fool them buy the new Super X-FI pci-e, we?ll promise them to be 00% crackling free."

Maybe you are looking for

  • Can't get songs into ipod

    I've got a new ipod and i'm trying to get all my songs on it that I have in i-tunes from my old ipod, and when I look at it through i-tunes it shows that all the songs are on my new ipod but when I disconnect it - the ipod has no songs on it. What am

  • HTMLEditorKit.Parser.parse() method is not giving a proper HTMLDocument alw

    Hi, I am developing util program for HTML filter, for my project. I have find using HTMLDocument we can do that. But when I created I found few starnge things. HTMLEditorKit.Parser.parse() method is not giving a proper HTMLDocument always. the below

  • Partition elimination using views

    Hi all, i am having problem with a view which is accessing all the partitions in my table. i have a table which has 30 columns and is partition by one column called cid. it is a list partition. when i do a query on the table, the explain plan show pa

  • Acelet announces LimpidDebugger 2.0

    Acelet announces LimpidDebugger 2.0. LimpidDebugger is a GUI debugger for LimpidLog, which is a revolutionary logging system: you do not need hard-code any log statement. SuperDebugger provides "Step in", "Step out", "Step over", "To break", "To curs

  • Help!!! Volume keeps dropping on some audio tracks,

    Hi im running logic studio, Recently got ALesis DM5 and EZdrummer. Now when i play a song in Logic or even record Volume on certain tracks just seem to drop,i move fader back up and it drops again. I am not using automation on any of theses tracks.It