|
I have a listbox with buttons and textblocks in its Data Template.
If I don't first click the list item, clicking the buttons operates on the wrong list item
Can I somehow automatically select the list item from within the data template?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
You can use the button DataContext instead of the list SelectedItem to obtain the correct object to operate on
Alternatively you can apply an ItemContainerStyle where you attach a PreviewMouseDown event in which you change the SelectedItem
|
|
|
|
|
I have a button who's comman's CanExecute is set to SelectedPhone != null.
When I click the button, the listbox seems to lose focus, and then SelectedItem is null, so the button becomes disabled.
How do I keep the listbox from losing focus, or SelectedItem from becoming null?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
I have a Company object, and it has a list of Phones on it.
In the UI, I have a Company listbox. The listbox's data template contains company info UI elements, as well as a second listbox with Phone numbers.
How do I set the ItemSource of the Phones listbox to the Company list's Phones collection?
I have this for the Company listbox:
<ListBox Grid.Row="2"
x:Name="AddressList"
ItemsSource="{Binding Addresses}"
SelectedItem="{Binding SelectedAddress}"
BorderBrush="Transparent"
BorderThickness="0"
Visibility="Visible"
Margin="5">
and this for the Phone listbox:
<ListBox Grid.Row="1"
ItemsSource="{Binding DataContext.SelectedAddress.Phones, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}"
Background="LightSalmon"
MinHeight="100"
BorderThickness="0"
Margin="5">
Problem is, when the selected item changes on the Company listbox, I see the same phone numbers in each phone section.
What's the right way to do this?
Thanks
If it's not broken, fix it until it is
modified 9-Jun-14 15:51pm.
|
|
|
|
|
I am designing this UI[^].
A location can have one or more addresses. Each address can have one or more Phones, Emails, and Internets. Clicking a location in the tree will load all addresses for that location.
The center "Address" area is a listbox. The ListItem's DataTemplate is comprised of an outer expander with the Street Address area.
Under that are the 3 other expanders for Phones, Emails, and Internets. Each of those expanders contains the Add/Remove buttons and a listbox. The ListBox's Data Template contains the controls for that area.
So far, pretty straight forward.
Ok, now the problem. See this[^]
The Address list is bound to an ObservableCollection<companyinfoheaderentity> called Headers. The CompanyInfoHeaderEntity contains an ObservableCollection<phoneentity> of PhoneEntities called Phones.
It's a typical hierarchical data model.
So why is the SelectedItem of the parent getting data from other Addresses?
Is there a better way to design this?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
I have a project with me, pls contact me to send the project.
|
|
|
|
|
That is not how it works. No one is going to take a "project" from an unknown source containing who knows what, debug it for you, fix it for you and send it back to you. You need to edit your posting to include a proper description of your problem.
|
|
|
|
|
Hi Chaps (and chapettes)
annoyance - when i am building my WPF app in VS 2013 - i have a form that keeps loading(and displaying) when i build if i have that from's XAML in the designer
whats the fix here?
cheers
Bryce
MCAD
---
|
|
|
|
|
There isn't a fix. This is the way Visual Studio works.
|
|
|
|
|
Switch to a different tab, something other than the XAML, before you build
If it's not broken, fix it until it is
|
|
|
|
|
I have a listbox with a data template[^] with a bunch of controls in it.
When I click a list box item OUTSIDE the template, I get the list item selected. You can see the blue bar around it.
But, if I start by clicking any item INSIDE the data template, the list item is NOT selected.
How do I solve this?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
I am creating a WPF desktop application to be run on both Windows 7 and Windows 8, and on both desktop computers and tablets. I need to pop up the on-screen keyboard (osk.exe) when a TextBox control GotFocus but only if no physical keyboard is connected.
I am using GetRawInputDeviceList() and GetRawInputDeviceInfo() functions to find the keyboard devices.
When I run my app on the Surface Pro without physical keyboard attached it detects one keyboard with the following information:
Keyboard:
Name = \\?\HID#VID_045E&PID_079C&MI_01&Col03#8&c93f0be&0&0002#{884b96c3-56ef-11d1-bc8c-00a0c91405dd}
Handle: = 18024907
KeyboardMode = 1 | NumKeysTotal = 6 | Subtype = 0 | Type = 81 | VendorID 81 | Usage 0 | ProductID 0 | VersionNumber 1 | NumIndicators 3
When I run it on the Surface Pro with physical keyboard attached it detects two keyboards with the following information:
Keyboard:
Name = \\?\HID#VID_045E&PID_079C&MI_02&Col01#8&17434d04&0&0000#{884b96c3-56ef-11d1-bc8c-00a0c91405dd}
Handle: = 43648689
KeyboardMode = 1 | NumKeysTotal = 154 | Subtype = 0 | Type = 81 | VendorID 81 |Usage 0 | ProductID 0 | VersionNumber 1 | NumIndicators 3
Keyboard:
Name = \\?\HID#VID_045E&PID_079C&MI_01&Col03#8&c93f0be&0&0002#{884b96c3-56ef-11d1-bc8c-00a0c91405dd}
Handle: = 18024907
KeyboardMode = 1 | NumKeysTotal = 6 | Subtype = 0 | Type = 81 | VendorID 81 | Usage 0 | ProductID 0 | VersionNumber 1 | NumIndicators 3
The only difference between these two keyboards is the numberOfKeysTotal field: one is 154, the other is 6.
My question:
How can I tell if a keyboard device is physical or virtual? By NumberOfKeysTotal?
Thanks.
|
|
|
|
|
That's a "feature" of virtual devices that they try to look as "physical" as possible... It may be impossible to differentiate between a virtual and real keyboard.
Some hints to the values you saw:
\\?\HID it is a "Human Interface Device"
VID_045E the Vendor Identifier is 045e (a hexadecimal value)
PID_079C the Product Identifier is 079c (the vendor sets the identifier of their products)
Strange that both keyborads have the same ids... (copy paste error?)
|
|
|
|
|
No copy error. The properties for the physcal and virtual keyboards are identical except for the number of keys total property. The physical one has 154 keys while the virtual has 6 keys.
|
|
|
|
|
Hello,
I need to play multiple instances of a same media file on a system and delete the file whenever last instance is deleted/closed.
There is no UI involved in it and media is played/stopped on some triggers.
I have been able to play the file using MediaElement and I am able to listen to same song in parallel and stop them individually.
The issue occured while deletion of the media file.
MediaElement doesn't release the filestream on MediaElement.Close() and the file is not deleted. It gets deleted only after application is closed.
I feel it to be a timing issue between MediaElement.Close() and File.Delete() as it happens intermittently.
I wanted to delete the file in order to create memory by deleting unused file(s).
It can be reporduced by creating atleast 2 MediaElement whose Source(Uri) refer to same media file.
After playing both the MediaElement, we close the media and delete the file(s). Sometimes it deletes the file, sometime doesn't.
Appreciate any thoughts on this issue of file being locked by the MediaElement and unable to delete instantly.
Thanks in advance!
Praveen Raghuvanshi
Software Developer
|
|
|
|
|
Yes; it sounds like a "timing" issue (since it happens "sometimes"). Some things (like I/O) can happen asynchronously.
I would "queue" the name of the file and delete it on a separate thread; in a limited "retry" loop that sleeps a few milliseconds between tries. Run a timer / counter to see the best and worst case to satisfy your curiosity.
|
|
|
|
|
Thanks!!!
Praveen Raghuvanshi
Software Developer
|
|
|
|
|
Hello,
I am currently trying to implement a combobox to act similarly to the google search. It is working almost successfully, but I am having one last issue that I haven't been able to make any progress on all morning.
When the combobox gains focus, the first letter I type will get highlighted and if the user continues typing, it gets overwritten by the next letter typed. This is obviously frustrating and makes the functionality useless.
I have tried various settings to stop this from happening but so far nothing is successful. Has anyone experienced this problem in the past and can offer advice?
I found a post on SE with the same problem: https://stackoverflow.com/questions/17250650/wpf-combobox-auto-highlighting-on-first-letter-input[^] however the only proposed solution doesn't fix it and actually introduces more problems that I've noticed.
|
|
|
|
|
hi,
i am trying to display Alternative images in listbox
<ListBox AlternationCount="2" x:Name="lstTiles1" Margin="0" >
<ListBox.ItemTemplate>
<DataTemplate>
<canvas>
<Image Source="Images\Tiles\Folder-n-design(right).png" Name="imgLoadRight" Margin="0,10,0,0" Visibility="Collapsed" />
<Image Source="Images\Tiles\Folder-n-design(center).png" Name="imgLoadCenter" Margin="0,100,0,0" Visibility="Collapsed" />
<Image Source="Images\Tiles\Folder-n-design.png" Name="imgLoadLeft" Margin="0,100,0,0" Visibility="Collapsed" />
<TextBlock VerticalAlignment="Top" Text="{Binding Name}" FontSize="16" FontWeight="Bold" Margin="90,20,0,0" Foreground="Black" />
</canvas>
<DataTemplate.Triggers>
<Trigger Property="ItemsControl.AlternationIndex" Value="0">
<Setter TargetName="imgLoadRight" Property="Visibility" Value="Visible" />
</Trigger>
<Trigger Property="ItemsControl.AlternationIndex" Value="1">
<Setter TargetName="imgLoadCenter" Property="Visibility" Value="Visible" />
</Trigger>
</DataTemplate.Triggers>
</DataTemplate>
<listbox.itemtemplate>
help me to display the Alternative Images...
nazeerpc
modified 28-May-14 8:03am.
|
|
|
|
|
I am making a casino game. i want to make a Casino wheel which rotates ad stops at a point. Currently i am using a PNG file which is a image of a similar wheel and i am rotating it in context to an another image which contains a white ball only.
But this makes the project heavy due to images plus when the wheel is rotating, the view is blurred.
A concept that is in my mind is that i could make a jquery spining wheel and embeed it in silverlight user control. but it is last option .can any one help me in making a spinning wheel in 3d in silverlight with smooth transitions and should show the number in message box where it stops.
Thanks.
Vishal Kumar Singh
|
|
|
|
|
|
I have control element and when i am doing drag and drop then that control have not image effects while doing operation. so please tell me a running examples for my requirement.
Hint is here demo of requirement image while drag and drop in wpf.
Thanks in advance.
Kalu Singh
|
|
|
|
|
I want to know the best practice for reusing the resources in WPF. I am using lot of resources in my application. For example Resource A,B,C and D. Resource A is used in Control A, Resource B is used in Control B, Resource A,C,D is used in Control C.
I found below three ways but i want to know which one is the best practice.
1. Adding all the resource in a Resource Dictionary file and use the resource dictionary in all the Controls.
2. Create separate resource dictionary file for each resource and Merge only the required resource dictionary in controls.
3. Duplicating the required resource in each control.
|
|
|
|
|
I see only 2 options and an idiotic suggestion.
I would go for something in between, group the resources by functionality and create a number of "libraries"
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanks Mycroft Holmes ,
Mycroft Holmes wrote: I would go for something in between, group the resources by functionality
Take if the Resource A and B are grouped by functionality to a Single Resource File. What if i used this resource in Control A which requires only Resource A. Is it ok to have Resource B also in the same file event thought it is not required for control A?. My concern is also about the memory and Performance.
|
|
|
|