Castom ComboBox and lose binding
Hello. I'm trying to write my own ComboBox and I ran into a problem.
public class TestComboBox : ComboBox
public static readonly DependencyProperty SelectedCarProperty = DependencyProperty.Register("SelectedCar", typeof(string), typeof(TestComboBox), new FrameworkPropertyMetadata(null, OnSelectedCarPropertyChanged));
public TestComboBox()
this.Cars = new ObservableCollection<string>() { "Select Car", "BMW", "Mersedes", "Audi" };
this.ItemsSource = this.Cars;
this.SelectedItem = this.Cars[0];
public string SelectedCar
get { return (string)GetValue(SelectedCarProperty); }
set { this.SetValue(SelectedCarProperty, value); }
public IList<string> Cars { get; private set; }
protected override void OnSelectionChanged(SelectionChangedEventArgs e)
base.OnSelectionChanged(e);
this.SelectedCar = (string)SelectedItem;
private static void OnSelectedCarPropertyChanged(DependencyObject source, DependencyPropertyChangedEventArgs e)
var car = (string)e.NewValue;
var editor = (TestComboBox)source;
editor.SelectedItem = car;
When I try to install the default value, I lose the binding. If I commented this code, everything works fine.
this.SelectedItem = this.Cars[0];
How can I set the default value without losing binding to the VM
P.S
TestApp
I use this code.
<propgrid:PropertyGrid Margin="0,0,11,7">
<propgrid:PropertyGrid.Items>
<propgrid:PropertyGridCategoryItem DisplayName="Main">
<propgrid:PropertyGridPropertyItem Value="{Binding Car, Mode=TwoWay}"
DisplayName="Car">
<propgrid:PropertyGridPropertyItem.ValueTemplate>
<DataTemplate>
<wpfApplication1:TestComboBox SelectedCar="{Binding Value, Mode=TwoWay, RelativeSource={RelativeSource AncestorType={x:Type propgrid:IPropertyDataAccessor}}}" />
</DataTemplate>
</propgrid:PropertyGridPropertyItem.ValueTemplate>
</propgrid:PropertyGridPropertyItem>
</propgrid:PropertyGridCategoryItem>
</propgrid:PropertyGrid.Items>
</propgrid:PropertyGrid>
I found a solution my problem Ijust replacedthe code
this.SelectedItem = this.Cars[0];
with this
this.Loaded += (sender, args) =>
if (this.SelectedItem == null)
this.SelectedItem = this.Cars[0];
And now everything works fine
Similar Messages
-
How do i split a line in a csv file and populate a combobox and a textbox with the parts
What I'm trying to do is split the line and fill a combobox and with the selecteditem and the textbox with the value of the combobox selecteditem which is the second part of the line split.
Thanks in advance for the help or suggestions.Then you should create a class to represent the items in the ComboBox:
Public Class MyItem
Public Property PartA As String
Public Property PartB As String
End Class
...and add instances of this class to the ComboBox:
Try
Dim mydocpath1 As String = Environment.GetFolderPath(Environment.SpecialFolder.Desktop)
Dim mylines() As String = File.ReadAllLines(mydocpath1 + "\TextFile1.txt")
For Each line In mylines
Dim parts() As String = line.Split(","c)
Dim item As MyItem = New MyItem With {.PartA = parts(0), .PartB = parts(1)}
cmb1.Items.Add(item)
Next line
cmb1.SelectedItem = cmb1.Items(1) 'select second item
Catch ex As Exception
MsgBox(ex.Message)
End Try
Then you set the DisplayMemberPath of the ComboBox to the name of one property and bind the Text property of the TextBlock to the other one:
<ComboBox Name="cmb1" DisplayMemberPath="PartA" />
<TextBlock Text="{Binding ElementName=cmb1, Path=SelectedItem.PartB}" />
That should solve your issue.
Once again, please remember to mark helpful posts as answer to close your threads and remember that a new thread deserves a new question. -
[svn:fx-trunk] 11737: ComboBox and DropDownList bug fixes
Revision: 11737
Author: [email protected]
Date: 2009-11-12 13:25:33 -0800 (Thu, 12 Nov 2009)
Log Message:
ComboBox and DropDownList bug fixes
SDK-23635 - Implement type-ahead in DropDownList
Added code in DropDownListBase keyDownHandler to listen for letters and change the selection if there is a match. At some point, we should modify findKey and findString (I'll file an ECR for that). For now, I've just overridden findKey and cobbled together the logic from List.findKey and List.findString. In ComboBox, we override findKey to do nothing since ComboBox has its own logic that relies on textInput changes.
SDK-23859 - DropDownList does not reset caretIndex when selection is cleared
Fixed this in two places. In ComboBox.keyDownHandlerHelper, we update the caret index when ESC is pressed. In DropDownListBase.dropDownController_closeHandler, we update the caret index if the commit has been canceled (ie. ESC was pressed).
SDK-24175 - ComboBox does not select an item with ENTER when openOnInput = false
When the ComboBox was closed and the arrow keys were pressed, the selectedIndex was changed. When ENTER was pressed, it was committing actualProposedSelectedIndex, not selectedIndex. The fix is to override the selectedIndex setter to keep actualProposedSelectedIndex in sync if selectedIndex was changed. Usually it is kept in sync when the dropDown is opened.
SDK-24174 - ComboBox does not scroll correctly when openOnInput = false
When typing in a match, the caretIndex was changed, but not the selectedIndex (because matching when it is closed doesn't commit the value until you press ENTER or lose focus). When closed, the navigation keys were changing the selectedIndex relative to the previous selectedIndex. I updated this to change relative to caretIndex instead. In most cases, caretIndex and selectedIndex are equivalent while the dropDown is closed.
Other changes:
- Replaced some calls to dropDownController.isOpen with isDropDownOpen.
- Added protection RTE protection to ComboBox.changeHighlightedSelection
QE notes: None
Doc notes: None
Bugs: SDK-23635, SDK-23859, SDK-24175, SDK-24174
Reviewer: Deepa
Tests run: ComboBox, DropDownList
Is noteworthy for integration: No
Ticket Links:
http://bugs.adobe.com/jira/browse/SDK-23635
http://bugs.adobe.com/jira/browse/SDK-23859
http://bugs.adobe.com/jira/browse/SDK-24175
http://bugs.adobe.com/jira/browse/SDK-24174
http://bugs.adobe.com/jira/browse/SDK-23635
http://bugs.adobe.com/jira/browse/SDK-23859
http://bugs.adobe.com/jira/browse/SDK-24175
http://bugs.adobe.com/jira/browse/SDK-24174
Modified Paths:
flex/sdk/trunk/frameworks/projects/spark/src/spark/components/ComboBox.as
flex/sdk/trunk/frameworks/projects/spark/src/spark/components/DropDownListBase.asThis bug figures out also when creating a custom spark ComboBox, then trying to programatically update the userProposedSelectedIndex property. The proposed selected index is selected, but does not apply the same skin as when mouse is on rollover or item is selected due to up and down keys.
The issue seems like updating the status of the item renderer to rollover or selected to get the same skin applied.
Please could you attach DropDow nList.as that you edited ?
Thank you so much. -
Dynamic SQL and Bulk Bind... Interesting Problem !!!
Hi Forum !!
I've got a very interesting problem involving Dynamic SQL and Bulk Bind. I really Hope you guys have some suggestions for me...
Table A contains a column named TX_FORMULA. There are many strings holding expressions like '.3 * 2 + 1.5' or '(3.4 + 2) / .3', all well formed numeric formulas. I want to calculate each formula, finding the number obtained as a result of each calculation.
I wrote something like this:
DECLARE
TYPE T_FormulasNum IS TABLE OF A.TX_FORMULA%TYPE
INDEX BY BINARY_INTEGER;
TYPE T_MontoIndicador IS TABLE OF A.MT_NUMBER%TYPE
INDEX BY BINARY_INTEGER;
V_FormulasNum T_FormulasNum;
V_MontoIndicador T_MontoIndicador;
BEGIN
SELECT DISTINCT CD_INDICADOR,
TX_FORMULA_NUMERICA
BULK COLLECT INTO V_CodIndicador, V_FormulasNum
FROM A;
FORALL i IN V_FormulasNum.FIRST..V_FormulasNum.LAST
EXECUTE IMMEDIATE
'BEGIN
:1 := TO_NUMBER(:2);
END;'
USING V_FormulasNum(i) RETURNING INTO V_MontoIndicador;
END;
But I'm getting the following messages:
ORA-06550: line 22, column 43:
PLS-00597: expression 'V_MONTOINDICADOR' in the INTO list is of wrong type
ORA-06550: line 18, column 5:
PL/SQL: Statement ignored
ORA-06550: line 18, column 5:
PLS-00435: DML statement without BULK In-BIND cannot be used inside FORALL
Any Idea to solve this problem ?
Thanks in Advance !!Hallo,
many many errors...
1. You can use FORALL only in DML operators, in your case you must use simple FOR LOOP.
2. You can use bind variables only in DML- Statements. In other statements you have to use literals (hard parsing).
3. RETURNING INTO - Clause in appropriate , use instead of OUT variable.
4. Remark: FOR I IN FIRST..LAST is not fully correct: if you haven't results, you get EXCEPTION NO_DATA_FOUND. Use Instead of 1..tab.count
This code works.
DECLARE
TYPE T_FormulasNum IS TABLE OF VARCHAR2(255)
INDEX BY BINARY_INTEGER;
TYPE T_MontoIndicador IS TABLE OF NUMBER
INDEX BY BINARY_INTEGER;
V_FormulasNum T_FormulasNum;
V_MontoIndicador T_MontoIndicador;
BEGIN
SELECT DISTINCT CD_INDICATOR,
TX_FORMULA_NUMERICA
BULK COLLECT INTO V_MontoIndicador, V_FormulasNum
FROM A;
FOR i IN 1..V_FormulasNum.count
LOOP
EXECUTE IMMEDIATE
'BEGIN
:v_motto := TO_NUMBER('||v_formulasnum(i)||');
END;'
USING OUT V_MontoIndicador(i);
dbms_output.put_line(v_montoindicador(i));
END LOOP;
END;You have to read more about bulk- binding and dynamic sql.
HTH
Regards
Dmytro
Test table
a
(cd_indicator number,
tx_formula_numerica VARCHAR2(255))
CD_INDICATOR TX_FORMULA_NUMERICA
2 (5+5)*2
1 2*3*4
Message was edited by:
Dmytro Dekhtyaryuk -
Apex listener installed no test and set bind variables buttons
I have installed Apex listener and while creating restful service module i dont see test and set bind variables buttons in the source region.
I went through the many posts. Installed apex listener successfully.
getting http://localhost:8080/ords/ started message when i start the listener.
and using Apex URL as http://localhost:7780/pls/htmldb.
What are the possibilities for this issues?
Please help me on this.
Thanks
ChandranApex listener version is 2.0.9
Apex version is 4.2 -
My ipod screen is cracked and i can't sync my ipod to itunes because it is locked with a password and i can't enter the password because the heat sensor is messed up on the ipod becasue of the screen and i don't want to restore it and lose everything. What can i do?!
All you can do is to restore and thus erase the iPod unless you can get a data recovery company to preserve the data.
Place the iOS device in Recovery Mode and then connect to your computer and restore via iTunes. The iPod will be erased.
iOS: Wrong passcode results in red disabled screen
If recovery mode does not work try DFU mode.
How to put iPod touch / iPhone into DFU mode « Karthik's scribblings -
I have two iphone users sharing one apple id and itunes account. Can I snc both phones to the itunes account without sharing each others info i.e. photos, music, contacts? I am afradi to sync one and lose the information the other one has.
A solution would be to use Apple's iCloud to sync instead of iTunes. This requires the latest operating system, iOS 5. Now backups will be done to the cloud, and you can choose what gets synced across your devices by turning them off in iCloud settings (i.e. turn off Calendars, Photos, etc.).
-
So it seems that a LOT of people have been having this problem. (Being...)
Credit card being declined.
I have had 2 different indicators from iTunes that something I have done is wrong.
1. iTunes does not accept my security code.
-This could be caused by the details held by my card's company/bank not having the corresponding details on file.
This is not the case.
2. It mentioned that because my account had been accessed from another source (my iPhone) I now had to re enter my details to continue making purchases (which includes updating apps on iPhone).
So I re entered my details. Then a notification also came up telling me that I had an outstanding balance that had to be paid (honest mistake though I'd love to know how exactly anyone comes to owe iTunes) and that this particular payment source had been declined and I must enter valid details.
Well thats weird, because this card IS valid.
So here's how I see whats happened. I've tried to make a purchase. The payment was processed via my >>>DEBIT<<< MasterCard and was declined because I didn't have enough funds. This is fine. This happens all the time. Its cash. You go to pay for something, "you don't have enough, oh well you don't get the product". Except it would seem that iTunes has seen this as "Your credit card has declined, well, you must be some poor bloke who we may have some problem getting payment from so were going to put a hold on ALL future purchases you try to make on this card."
Oh, that's okay! I'll just go to my wallet and get another one of my 1,000,000 other credit cards I have and just use that. That's right, I don't have one.
It would have been fine if iTunes allowed you to just select "none" as a payment method because that way I could re-enter my card details (which now has money in it) and it would be processed just fine. But no. iTunes will no longer accept my card and my account and all of it's apps have been put on hold.
My only choice seems to be to apply for a credit card for the sake of a 99c app. Brilliant.so now I have to close an account I've held for 5 years and lose all my content...... am I right?
No.
I suggest you contact iTunes support.
-> http://www.apple.com/support/itunes/contact/
and was declined because I didn't have enough funds. This is fine. This happens all the time. Its cash.
I wouldn't say "this is fine" and it is not cash.
In many places, attempting to use a debit card with no funds (even if you don't know there are no funds) is fraud and is illegal. -
Dynamic view object loses bind variables after passivation
I am creating a view object definition/view object programmatically in Jdev 11.1.1.2.0. The query requires a named bind parameter. All was working fine but now I am testing with app module pooling disabled and the bind variable is not being restored after passivation -- it's like the definition has disappeared or something.
Here is my VO creation code:
ViewObject vo = findViewObject("FinalistsWithEvalDataVO");
if (vo != null){
vo.remove();
ViewDefImpl voDef = new ViewDefImpl("FinalistsWithEvalDataVODef");
// I add a bunch of viewAttrs here...
voDef.setQuery(fullQuery);
voDef.setFullSql(true);
voDef.setBindingStyle(SQLBuilder.BINDING_STYLE_ORACLE_NAME);
voDef.resolveDefObject();
voDef.registerDefObject();
vo = createViewObject("FinalistsWithEvalDataVO", voDef);
vo.defineNamedWhereClauseParam("Bind_SchlrAyId", null, new int[] {0});
vo.setNamedWhereClauseParam("Bind_SchlrAyId", new Number(1)); //For testing
vo.executeQuery();
The query executes fine right there and then the VO seems to passivate fine. I even see the bind var in passivation:
<exArgs count="1">
<arg name="Bind_SchlrAyId" type="oracle.jbo.domain.Number">
<![CDATA[1]]>
</arg>
</exArgs>
But then when it reactivates prior to rendering the page, it invariably throws a missing parameter exception and this in the log:
<ViewUsageHelper><createViewAttributeDefImpls> [7409] *** createViewAttributeDefImpls: oracle.jdbc.driver.OraclePreparedStatementWrapper@1af78e1
<ViewUsageHelper><createViewAttributeDefImpls> [7410] Bind params for ViewObject: [FinalistsWithEvalDataVO]AwardViewingServiceAM.FinalistsWithEvalDataVO
<ViewUsageHelper><createViewAttributeDefImpls> [7411] ViewUsageHelper.createViewAttributeDefImpls failed...
<ViewUsageHelper><createViewAttributeDefImpls> [7412] java.sql.SQLException: Missing IN or OUT parameter at index:: 1
I have worked on this for hours and can't see anything wrong. Like I said, it works fine when not forcing passivation...
Any help would be appreciated.
Thanks.
-Ed@Jobinesh - Thanks for the suggestions. I have read all the documentation I can find. Everything works fine without passivation. Everything still breaks with passivation. I have given up on trying to get the bind variable to restore after passivation and am currently just building the query with all values embedded in the query rather than bind variables. This is bad practice but avoids the problem. However, now that I avoided that obstacle, I'm on to the next issue with passivation of this dynamic view object, which is that the current row primary key apparently cannot be reset after activation. I get the following error:
<Key><parseBytes> [7244] Key(String, AttributeDef[]): Invalid Key String found. AttributeCount:1 does not match Key attributes
<DCBindingContainer><reportException> [7254] oracle.jbo.InvalidParamException: JBO-25006: Value 00010000000A30303033383133343734 passed as parameter String to method Constructor:Key is invalid: {3}.
at oracle.jbo.Key.parseBytes(Key.java:537)
at oracle.jbo.Key.<init>(Key.java:179)
at oracle.jbo.server.IteratorStateHolder.getCurrentRowKey(IteratorStateHolder.java:34)
at oracle.jbo.server.ViewRowSetIteratorImpl.activateIteratorState(ViewRowSetIteratorImpl.java:3877)
I've been trying various workarounds for over a day now with no luck. Very frustrating.
Thanks for trying to help.
-Ed -
My old computer crashed and I have a new computer. How can I save my music from my IPod to the new computer since it isn't in my Library. I don't want to sync and lose music.
Then you will need to search for a 3rd party program to transfer content
Pasted from another thread
https://discussions.apple.com/thread/2234756?start=0&tstart=0
One of the most recommended is Yamipod. This is a free program that transfers music from iPod back to the computer. However, it does not transfer playcounts/ratings etc.
Other free programs are Pod Player, SharePod and Floola and iDump andiPodRobot.
If you want to recover just the structure of playlists from the iPod (and not the actual song files themselves), there's iRepo for Windows. which I understand has this feature along with all the standard features for these programs.
iPodRip also has the feature enabling you to reconstruct playlists.
There is also CopyTrans. This does preserve ratings/playcounts etc if those are important to you but this program is not free. It also supports video transfer.
More information is contained here.
Copying content from your iPod to your computer - The Definitive Guide. -
Itunes is not letting me add songs from my new computer to my iphone.
Instead it wants me to sync my music library and lose all the songs on my phone. i have over 700 songs i cannot lose them just because i want to add 10 new songs... PLEASE HELP. also i am using the new CONFUSSING ITUNES 11.This has always been the case.
All iphones have always only synced to one computer at a time.
Syncing to another will indeed erase the current content and replace with content from the new computer.
Copy everything from your old computer, or your backup copy of your old computer, to the new one. -
I have just installed 10.7 and bootcamp is no longer visible on my desktop, nor can i start computer in windows mode. I started the bootcamp 4.0 upgrade assistant, but don't want to wipe windows 7 out and lose my data. Any suggestions?
I have just installed 10.7 and bootcamp is no longer visible on my desktop, nor can i start computer in windows mode. I started the bootcamp 4.0 upgrade assistant, but don't want to wipe windows 7 out and lose my data. Any suggestions?
-
How do I manually transfer music with the new itunes update for Windows? I don't want to sync my library and lose all of my music for what I have in my current library.
The same way it was done in every previous version.
Connect the device to the computer.
Right click on the device in iTunes and select Transfer Purchases.
Why would you lose any content by syncing with iTunes?
Is this not the computer that the device is normally synced with? -
Tried running disk repair from HD recovery, not repairable. Trying to reinstall OSx Lion, says disc is locked. Do I have to erase the drive and lose everything? I also have Bootcamp installed, will boot to Windows no problem.
Hotrodmkviii,
try rebooting in Recovery mode, but when you reach the Mac OS X Utilities menu, run Terminal (from Utilities in the menu bar) instead. Inside the Terminal window, give it the following command, and then press the Return key:
diskutil list
Please include in your reply the output from that command. -
Please can anyone help? My brother has given me his old iPod 1st Gen 30GB. It has loads of music on it that I love and don't want to lose however there is quite a bit of stuff that I really don't want. How can I remove the songs I don't like without having to reset the iPod and lose the songs I do like. I'm sure there's an easy answer but I just can't figure it out!!
Hi there, there doen't seem to be any option to "select songs and videos" so this hasn't helped I'm afraid. I guess I'll just have to accept the fact that I'm going to have to reset and lose the lot.
Maybe you are looking for
-
I have an ipod touch that hasn't been used in a while. We want to use it now, but the screen says "ipod disabled. connect to itunes". When I connect to itunes it tells me to enter my passcode, however the ipod will not allow me to do anything (and
-
My iPod Touch was working fine yesterday and there is no heat or water damage. Then, it died, like it normally does after it's used for a long period of time. So, I went to charge it in a wall outlet (like usual) and the battery symbol with the light
-
Use abap class event as terminating event
Hi, The class is say ZCL_WF_CLASS and the event END_WF. What needs to be done to have this event used correctly as a terminating event of a workflow? Does this event require a parameter to hold the workitem id (or workflow id), as currently this
-
Hi All, I am working in sandbox. While creating standard sales order, after entering material no. and quantity, I am getting error as version 0 is not maintained in fiscal year 2009. Please guide. Regards,
-
Hi Does anyone know if we can make 'COUNTY' field required when customer creates ship to address on the fly. This is just for US only as county concept is more appropriate for US. Please respond Thanks