|
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.
|
|
|
|
|
Sorry, I have not considered memory usage as an issue since the 90s but I would not hesitatein using 2 resource libraries for a single control.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi!
I have a WpfApplication with a TreeView and a Button.
<Window x:Class="WpfApplication1.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:WpfApplication1"
Title="MainWindow" Height="350" Width="525">
<Grid>
<TreeView Name="tvTree">
<TreeView.ItemTemplate>
<HierarchicalDataTemplate ItemsSource="{Binding List}" DataType="{x:Type local:BaseNode}">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Header}" />
</StackPanel>
</HierarchicalDataTemplate>
</TreeView.ItemTemplate>
</TreeView>
<Button Width="20" Height="20" Content="Click" Click="Button_Click" />
</Grid>
</Window>
The TreeView's ItemsSource property will be populated from a list based on the BaseNode class. That class look like this:
public class BaseNode
{
System.Collections.ObjectModel.ObservableCollection<BaseNode> list = new System.Collections.ObjectModel.ObservableCollection<BaseNode>();
string header;
public BaseNode(string header)
{
this.header = header;
}
public string Header
{
get { return header; }
set { header = value; }
}
public System.Collections.ObjectModel.ObservableCollection<BaseNode> List
{
get { return list; }
set { list = value; }
}
}
The MainWindow.cs have this code:
public partial class MainWindow : Window
{
BaseNode a = new BaseNode("Base");
BaseNode b = new BaseNode("Sub1");
BaseNode c = new BaseNode("Sub2");
BaseNode ba = new BaseNode("Sub1Sub1");
BaseNode baa = new BaseNode("Sub1Sub1Sub1");
public MainWindow()
{
InitializeComponent();
a.List.Add(b);
a.List.Add(c);
b.List.Add(ba);
ba.List.Add(baa);
tvTree.ItemsSource = a.List;
}
private void Button_Click(object sender, RoutedEventArgs e)
{
b.Header = "NewHeader";
}
}
Question 1:
When I click the button I would like to change the Header property of one of the BaseNodes. But the code for the Button.Click event won't do the trick. Just setting the BaseNode.Header property seem not to be enough. Instead I need to alter the Button.Click callback to:
private void Button_Click(object sender, RoutedEventArgs e)
{
b.Header = "NewHeader";
tvTree.ItemsSource = null;
tvTree.ItemsSource = a.List;
}
This does the job but seem to be very overkill for such a small thing.
Is there a better way to make the TreeView show the new value of the BaseNode.Header property?
Question 2:
Image I have populated the same TreeView with a bunch of BaseNode objects forming a tree with many branches of BaseNodes as well as branches in branches. I lack a way to, manually by code, open or close a branch in the TreeView.
I have found out that this is supported for the TreeViewItem control which have the IsExpanded property. My BaseNode class don't have such a property and including one I highly doubt it will "solve the problem".
With the TreeView.SelectedItemChanged event I can select any BaseNode in the TreeView and find out the actual BaseNode instance I selected. From this point I would like to be able to open or close the nested BaseNodes.
How to open or close a nested node in the TreeView which is not a TreeViewItem?
Best regards
/Mc_Topaz
|
|
|
|
|
In regards to Question #1, your BaseNode needs to PROPERLY implement INotifyPropertyChanged on the Header and List properties.
In regards to Question #2, yes, the IsExpanded property is in the TreeViewItem. HierarchialDataTemplate doesn't support binding to that out of the box. However, you can easily derive a class HierachialDataTemplateEx which exposes an IsExpanded property and override the ValidateTemplatedParent method and bind it to TreeViewItem.
|
|
|
|
|
Thanks SledgeHammer01!
I solved Question 1.
But I don't understand how to solve Question 2 by your explanation. I derived the HierarchicalDataTemplate class to this:
public class HierachialDataTemplateEx : HierarchicalDataTemplate
{
bool isExpanded = false;
public bool IsExpanded
{
get { return isExpanded; }
set { isExpanded = value; }
}
protected override void ValidateTemplatedParent(FrameworkElement templatedParent)
{
}
}
But I'm stuck after that. Can you continue my code and point me in the correct direction?
Also I got some further question for this solution:
1) Does this mean I need to stop using my BaseNode class and use TreeViewItem instead?
2) Using an derived version of HierarchicalDataTemplate class, does this mean my XAML code for the TreeView must be altered?
/Mc_Topaz
|
|
|
|
|
The way you have it set up above, you'll only be able to control the IsExpanded "once" (at creation of the node). I.e. create a node expanded. If that is not sufficient and you need to be able to expand and collapse at will, you'll need to go a slightly different route. It is more complicated, so I won't go into that unless you need it .
Yes, you will need to slightly modify your XAML (assuming your namespace is local):
<local:HierarchialDataTemplateEx IsExpanded="True" ... >
</local:HierarchialDataTemplateEx>
In your ValidateTemplateParent() method, you just do something like:
base.ValidateTemplatedParent(templatedParent);
// set the properties on the TreeViewItem
if ((object)templatedParent != null)
{
TreeViewItem tvi = templatedParent.TemplatedParent as TreeViewItem;
if ((object)tvi != null)
tvi.IsExpanded = IsExpanded;
That should be sufficient for most use cases (creating a node in its expanded state). As I mentioned above, you need to do additional stuff if you need to control expansion state dynamically or get the node expansion state at runtime for saving expansion state, etc.
However, this basic way will let you for example create the top level expanded and the rest of the levels collapsed.
|
|
|
|
|
Thanks again and for your effort!
I need to re-evaluate this. Maybe I don't need this full control of the TreeView.
|
|
|
|
|
I am building a WPF application in which I need to do some OCR. I understand that it is possible to use the Microsoft Office Document Imaging 12.0 Type Library in Office 2007. However, I want my application to run also without office 2007 installed. Is there a separate download of Microsoft Office Document Imaging 12.0 Type Library that I can use for this purpose. I assume that all I need to do is to reference the appropriate dll in my application - correct?
NOTE: in local system my WPF Application working Fine.
Local system having Office 2007. but i want to run with out office..
any solution.... plz.
Nazeerpc
|
|
|
|