.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
Sharon Maxwell
Post New Web Links

ListBox with a Canvas, strange selection behaviour

Posted By:      Posted Date: October 26, 2010    Points: 0   Category :WPF
 

Hello,

 

I have a Listbox with a Canvas asigned to the ItemsPanelTemplate:

<ListBox x:Name="CanvasListBox" SelectionMode="Multiple" SelectionChanged="CanvasSelectionChanged">
	<ListBox.ItemsPanel>
		<ItemsPanelTemplate>
			<Canvas />
		</ItemsPanelTemplate
                                     
                                            
                                        

View Complete Post


More Related Resource Links

ASP.NET DateTime Conversion strange behaviour

  

Hi,

I am working on ASP.NET web application where we are using javascript calendar to accept the date in textboxes. The date format is dd/mm/yyyy. The application is running in US and UK environments.

I am facing issues in US environment while storing the dates so I have added 2 keys in config file viz culture which will be either en-US or en-GB depending on the deployment location and baseCulture which will always be en-GB.

In the code, I have added a condition which checks if culture and baseCulture values are not matching then do the conversion of date in US format.

But I have found that the code converts the date from dd/mm/yyyy to mm/dd/yyyy when the key is baseCulture (en-GB) and it throws FormatException when key is culture (en-US).

I am bit confused by this behaviour. Is this normal? Can any one please explain more about this? Note: I am working on a machine which has en-US as language and culture

<add key="culture" value="en-US" />
<add key="baseCulture" value="en-GB" />
// This line works and converts the date from 26/08/2010 to 08/26/2010
// Here the baseCulture is en-GB.
DateTime dt = DateTime.Parse(txtCurrentDate,baseCulture)

// This line throws FormatException. culture 

VERY strange behaviour of IE7 and 8!

  
Today is a day where nothing seems to work out as expected.I'm currently making the HTML and Javascript templates for our new Corporate Page.The thing works as expected in Firefox, Opera, Chrome and IE 6, but not in IE 7 and 8!The "thing" is a menu/submenu written by me in javascript.The way it looks in Firefox etc:The way it looks in IE 7 and 8:There is absolutely no explanation for the strange "rounded" edge on the right and the gradient going over it.The background is a semi-transparent optimized PNG without color profiles which shows up gray in IE 6 and transparent in the other browsers - as expected.On my other developer's computer, it shows up perfectly in both IE 7 and 8.What could possibly create this behaviour?----source:<div class="subMenusContainer"> <div class="subMenu" id="aboutUsMenu"> <a href="/Home/AboutAurora">About AURORA</a> <a href="/Home/AboutErichKrammer">Erich Krammer</a> <a href="/Home/AboutFoundation">AURORA Foundation</a> <a href="/Home/AboutPartners">Partners</a> <a href="/Home/AboutCareers">Careers</a> <a href="/Home/AboutContact">Contacts</a> </div> [snip] <div class="subMenu&q

ListBox/ListView Selection

  
We are implementing drag/drop on ListBox/ListView items with the extended selection mode. The extended selection mode allows multiple items to be selection simultaneously by holding the shift or control key while selecting additional items.   In Windows Explorer, when an individual item among a group of selected items is clicked, all of the other items are not deselected until the up-click event. This allows an individual to select the desired group and then click and drag this group as a whole to the desired destination.   In WPF, the group appears to be deselected and the individual item selected on the down-click event. This means that in order to drag a group of items, you must hold shift, click and hold the mouse on the desired range of items and then drag the group. If the group is selected first and then the mouse released, the individually clicked item is selected when a drag attempt is made on the group.   We are using WPF, but would like to see the Windows Explorer selection functionality. Any thoughts on how to reconcile these two implementations? The most straight forward fix would be a custom control, possibly derived from ListBox/ListView, but this seems like it might be reinventing the wheel. Seems like the WPF controls are not designed properly here.   Thanks.

Strange behaviour of a query using a recursive CTE

  
Hi, I have a problem with a query. The situation is a bit complicated but I'll try to explain it the best I can. Short story: I have a .NET application that executes a recursive query (using CTE) and then uses a DataReader to read each row's each field one-by-one using the GetValue() method. With specific parameters this query behaves quite fast but with other parameters it can take more than a second to read a row's field (instead of the usual ~0.00001 second). Long story: The database: I have 4 tables with the following columns: 1. Entity table: Id (int), Version (bigint), InternalName (nvarchar(255)), ExternalName (nvarchar(255)), Description (nvarchar(2,000)). 2. Relation table: Id (int), Version (bigint), EffectiveStartTime (datetime), EffectiveEndTime (datetime), ParentEntityId (int), ChildEntityId (int), Ordinal (int). 3. Property table: Id (int), Version (bigint), InternalName (nvarchar(255)), ExternalName (nvarchar(255), Description (nvarchar(2,000)). 4. EntityProperty table with 10,000 rows: Id (int), Version (bigint), EffectiveStartTime (datetime), EffectiveEndTime (datetime), EntityId (int), PropertyId (int). The Entity table has 100,000 rows, the Relation table has 100,000 rows (each entity has a relation), Property table has 22 rows and the EntityProperty table has 2,010,000 rows (properties with Id from 1 to 20 are assigned to all entities and properties with

Strange behaviour of a query using a recursive CTE

  
Hi, I have a problem with a query. The situation is a bit complicated but I'll try to explain it the best I can. Short story: I have a .NET application that executes a recursive query (using CTE) and then uses a DataReader to read each row's each field one-by-one using the GetValue() method. With specific parameters this query behaves quite fast but with other parameters it can take more than a second to read a row's field (instead of the usual ~0.00001 second). Long story: The database: I have 4 tables with the following columns: 1. Entity table: Id (int), Version (bigint), InternalName (nvarchar(255)), ExternalName (nvarchar(255)), Description (nvarchar(2,000)). 2. Relation table: Id (int), Version (bigint), EffectiveStartTime (datetime), EffectiveEndTime (datetime), ParentEntityId (int), ChildEntityId (int), Ordinal (int). 3. Property table: Id (int), Version (bigint), InternalName (nvarchar(255)), ExternalName (nvarchar(255), Description (nvarchar(2,000)). 4. EntityProperty table with 10,000 rows: Id (int), Version (bigint), EffectiveStartTime (datetime), EffectiveEndTime (datetime), EntityId (int), PropertyId (int). The Entity table has 100,000 rows, the Relation table has 100,000 rows (each entity has a relation), Property table has 22 rows and the EntityProperty table has 2,010,000 rows (properties with Id from 1 to 20 are assigned to all entities and properties with

Drop Down Listbox SelectedIndexChanged Event not firing when I programmatically change selection

  
I have two drop down listboxes (DDL1 and DDL2).  When DDL1 has an index change, DDL2 then has a refresh of list items based off SQL Server SELECT from a table.  The database isn't the problem.  Everything works perfectly when the user selects a new item manually from DDL1.But in my code, I save the user data from the selection of DDL1 in a separate table.  And then upon rendering of the page (Page_PreRenderComplete), I do a SelectedIndex assignment of the value of what's saved in the db table.  That works just fine, it selects the DDL1 item, but DDL2 is unaffected, as if DDL1's SelectedIndexChanged event isn't called like it would be if manually changed.  How can I get around this?Thanks in advance. :)

ListBox.SelectedItem stuck at whatever is first selected and other strange ListBox behavior

  
Hi, I've built a List<Participant> (Participant being my custom type) and assigned this to ListBox.ItemsSource. (I'm aware this is more the Windows Forms way than the WPF way of databinding, but I'd still like to understand what's going on here - even though suggestions on how to perform my task in a more WPF-y way are also welcome.) I've set ListBox.SelectionMode to Single, and attached an event handler to the SelectionChanged event. In this handler, I dump the SelectedIndex and SelectedItem to debug output. Contrary to my expectation, 1) SelectedIndex is always -1. This isn't really causing me any trouble, but it's certainly not what I'd expect. 2) SelectedItem refers to the correct object the first time (in the windows lifetime) I select an item, but then keeps referring to this first-selected item regardless of whether I deselect (by clicking the item again while holding down the CTRL key) or select some other item. 3) If I keep clicking around and scrolling a bit (the list has ~320 items) within the list, now and then the list suddenly displays a bunch of items - sometimes many in a row, sometimes non-contiguous items, but it seems always "nearby" items! - as if they were selected. The list keeps firing the SelectionChanged event, but SelectedIndex is forever -1 and SelectedItem (and SelectedValue) always refers to whatever I had selected the fir

Multiple Listbox Selection not working :(

  
I'm loading a ListBox this way, which works and shows the selected items: lstCollectionsType.SelectedValuePath = "ClientCollectionTypeID"; lstCollectionsType.DisplayMemberPath = "ClientCollectionType1"; lstCollectionsType.ItemsSource = MyClient.ClientCollectionTypes; foreach (ClientCollectionType item in MyClient.ClientCollectionTypes) { if ((bool)item.Selected) lstCollectionsType.SelectedItems.Add(item); } And when trying to save the data, I do it as shown below. But it's not getting the current selected data. It's showing the data of how it was loaded. Make sense? It's not changing what is selected. foreach (ClientCollectionType i in lstCollectionsType.Items) { if (i != null) { ClientCollectionType boo = MyClient.ClientCollectionTypes.SingleOrDefault(c => c.ClientCollectionTypeID == i.ClientCollectionTypeID); if ((bool)i.Selected) boo.Selected = true; else boo.Selected = false; } } Please help! Thank you so much for your time!

WPF - strange context menu behaviour

  

Hi 

I create contextmenu using that code

 

 protected MenuItem itemAdd, itemDelete, itemSelectBranch, itemDeleteClasp;
  protected MenuItem itemCut, itemCopy, itemPaste, itemAddParent, itemPasteWithChildren;
  protected MenuItem itemAddTask, itemAddExtTask, itemAddMileStone;
 menu = new ContextMenu();
    itemAdd = new MenuItem
           {
             HorizontalAlignment = HorizontalAlignment.Left,
             HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch,
             Header = "Add"
           };
    itemDelete = new MenuItem
             {
               HorizontalAlignment = HorizontalAlignment.Left,
               HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch,
               Header = "Delete"
             };
    itemSelectBranch = new MenuItem
    {
      HorizontalAlignment = HorizontalAlignment.Left,
      HorizontalContentAlignment = System.Windows.HorizontalAlignment.Stretch,
                  Header = 

Strange validation behaviour on dynamically created controls

  

I'm trying to debug an application which generates a fixed number of questions from a database of 20 questions, and validate them on button click. On postback, I want the incorrect questions to be labeled red. However, all the questions are labeled red on postback. I'm almost positive that the problem is with "page_init" and "page_load",  I'm using session variables to keep track of the question IDs and invalid questions. Any help is appreciated.

Here is the sample code.

Protected Sub Page_Init(ByVal s As Object, ByVal e As EventArgs)
       dim i as integer
       if Not Page.IsPostBack then
           // generates a random integer array for loading the questions
       For i = 0 To 1  // I'm only loading two questions 
           extract_question(selected_array(i))   
        Next
        else     
              //extract_question queries the database and load the controls dynamically
               extract_question(CInt(session("check_0")))  
               extract_question(CInt(session("check_1")))           
         end if      
       end if 
    
    End Sub

Protected Sub Page_Load(ByVal s As Object, ByVal e As EventArgs)
        If page.IsPostBack then
         dim textlabel as string
            dim sessionvar as string
            dim sessionc

Very strange behaviour from WPF binding

  

 

I am currently using markup like the following:

 <Binding diagnostics:PresentationTraceSources.TraceLevel="High" RelativeSource="{RelativeSource Self}" Path="(PatientControls:Entity

Strange sorting behaviour on series groups

  

Hi guys

I'm seeing some very strange behaviour when trying to sort my series groups on a chart.

I have an Analysis Services dataset with Job Grades and Job Grade Codes, the job grade simply being a concatenation of the Job Grade and the word "GRADE", e.g.

1 |  GRADE 1

2 |  GRADE 2

3 |  GRADE 3 etc.

I've pulled in the field Job_Grade into my Series groups section for a chart. I then tried to sort it by the key value which is the Job_Grade_Code like this:

=Fields!Job_Grade.Key

This produced the following result:

 Grade 6

Grade 7

Grade 8.....

Grade 4

Grade 5

I noticed that the sorting was incorrect. I noticed that in the source the Job_Grade_Code field was a varchar value, so I changed the sorting expression to the following:

=Cint(Fields!Job_Grade.Key)

This however made no difference and still sorted my grades in the incorrect order

Strange Behaviour of For Loop

  

Hi Friends,

I am getting Strange behaviour from the for loop.

Here is the loop

for(i=1, i<=1000000, i++)

{

label1.text = string1;( string 1, 2 , 3 comming from logic)

label2.text = string2;

label3.text = string3; 

label4.text = string4;

once i got them i storing in the table of sql server using following steps,

SqlConnection conn = new SqlConnection();
                     conn.ConnectionString = " connectionstring ";
                     SqlCommand cmd = new SqlCommand();
                     cmd.CommandType = System.Data.CommandType.Text;
                     cmd.CommandText = "INSERT INTO table(value1, value2, value3, value4, value5) VALUES( @i, @value1,@value2,@value3,@value4)";
                     cmd.Parameters.Add(new SqlParameter("@i", i ))

SSAS: Strange filter behaviour in client

  

Hi,

 

In my cube I have one Time dimension that I use for filtering my data. The way I select my check boxes in the Time dimension influences the shown data. I checked the created filter by using SQL Server Profiler and this shows that the created filter is totally wrong!

 

Scenario 1 (NOK)

 

Steps

·        

Strange behaviour taxonomy filter in content query webpart on anonymous website

  

We are experiencing strange behaviour on a publishing facing website implemented in SharePoint 2010.

The story
We use a (default) Content Query Webpart to show related information in relation with the current page. The filter is using a field value (UserFieldValue) of the current page and filters other pages which have the same tags. The fields, on the current page and the related pages, are taxonomy field. Everything works fine!

We published the pages, looked at the website as an anonymous user and everything was still going smoothly. We went home, slepts an hour of 6, waked up. Proudly checked our beatifull new website :). Ahhhhh, what is this.. all content query webpart with the filters on the taxonomy field returned exactly nil.

We logged in to our website, checked if the pages where published, and well, they are... Just published them again. And everything looked fine again.... but not for long. Exactly the next day (... app pool recycle ...) the same problem ...

Logged in again to our website, logged out...  problem solved.... till the next apppool recycle.

My conclusion
Until the firrst authenticated visit to the page the taxonomy filter on the content query webpart silenty fails.

Resolution
As a "temporary" workarround we have created a sc

Extending OutputResponseStream but some strange behaviour???

  

Hi

I have trying to write a HttpHandler to Filter some content before rendering. As HttpApplication.Context.Response.OutputStream does not support manipulatiing at this stage. so, for remedy i am extending it to customize Write method

here is the code

using System;
using System.Data;
using System.Configuration;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Text.RegularExpressions;

namespace WebApplication1
{
    public class StdViewStateRemover : System.Web.IHttpModule
    {
        private System.Web.HttpApplication mApplication;

        public StdViewStateRemover()
        {
        }

        public void Init(System.Web.HttpApplication application)
        {
            // Wire up beginrequest
            application.BeginRequest += new System.EventHandler(BeginRequest);
            // Save the application
            mApplication = application;
        }

        public void BeginRequest(Object sender, EventArgs e)
        {
            //for testing purposes i just checking jpg images
            if (((HttpApplication)sender).Request.Path.ToLower().Contains("jpg".ToLower()))
            {
                return

Different behaviour of Chart vs ListBox

  

Hi,

I have a Chart control. I am Binding some Data.

I have a listbox, I am binding same data, as I bound to chart.

Here are XMAL

 

 <DockPanel Width="300" >
  <ComboBox x:Name="_cmbLevels"
     DockPanel.Dock="Top"
     HorizontalAlignment="Left"
     ItemsSource="{Binding Levels}"
Categories: 
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend