|
Your question is not very clear.
Maybe posting some code here can help!
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
Any idea how to do this? Auto completing multiple values separated by comma into a single autocompletebox. Something similar to gmail to/cc/bcc address textbox.
|
|
|
|
|
You might want to inherit the existing AutoCompleteBox control and right your own one.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
Hi,
I'm trying to create a custom control that behaves like an horizontal StackPanel that hosts hyperlinks (with rich ToolTip).
A major difference is that I want to have horizontal scrollbar and keep the size of the control as one line of text.
I did it by inherit from ListBox and set my own Template, ItemsPanel and ItemTemplate.
It worked fine when I did all the work in my test WPF application, but when I moved the code to a class library, like it should be, I have a problem with the scrollbar.
When the width of the control if too short, a scrollbar thumb apears (I deleted it in my control!) and hides my links.
Also, I can not click the links or see the ToolTips because when the mouse is over the control the scrollbar takes control.
It is hard to show code here because then I would need to show all the Generic.xaml, instead I uploaded the whole solution (very small):
Code Here
How do I cancel this behavior?
Thanks,
Yariv
|
|
|
|
|
Solved. It was a problem of hidden VisualState (MouseOver).
I just copied the default ScrollBar style from the MSDN (instead of using the template the Expression created for me), then edited what I want and...it works.
Thanks
|
|
|
|
|
Thanks for posting the solution here.
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
Hi,
I created new ResourceDictionary - This Resource is actually a button.
I want to add some behavior to this button => in case the user will press on the button then the button will
stay in "press" state until the user will "press" it again ( something like Caps Lock ) and i don't know how to do it.
I have on my code Trigger that will call and change the button color to 'red' color in case the user press on it - but the color will be 'blue' again ( the original color ) when the user stop pressing on the button.
How can i do it ?
Thanks for The help.
|
|
|
|
|
There is a control called ToggleButton that does exactly what you need.
|
|
|
|
|
Hi
I have a very basic WPF question. Please forgive my
ignorance.
I have Visual Studio Solution with two VB Projects:
Project A is a WPF program that contains x, x being an ObservableCollection(of Rec) where rec is a Class of some database record.
Project B is a UserControl uc, containing, amongst other things a ListBox lb. The problem is how to display the x items in lb. Project A contains several instances of uc.
Possible solution 1:
Is there a way that I can bind lb directly to x? I seem to be unable to do so.
Possible solution 2:
Should I define a dependency property of ObservableCollection(of Rec) in B and give that a value in the Xaml of the uc instances. This also fails! Conceptually, this method has me worried, because I cannot see how uc obtains the rec info for formatting the records
in its DataTemplate. I have to define the Property as a ObservableCollection(of Object) to get past the compiler!
Possible solution 3.
It cannot be done!
BTW, I know enough to display x in a listbox defined in A quite nicely with a DataTemplate.
I have searched Google long and hard without finding anything that throws light on my dilemma! Any insight will be much appreciated.
David
|
|
|
|
|
Hey David,
Working with listbox is very easy.
You put the object in Resource, say your class which has the ObservableCollection is in X.
class X
{
public ObservableCollection<MyObject> { get;set;} ....
}
in XAML
<Window.Resources>
<local:X x:Key="mycollection" />
</Window.Resources>
<ListBox DataContext="{StaticResource mycollection}" ItemsSource="{Binding}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding MyText}" />
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
So here the property MyText will be displayed in the list of MyObject .
You can also use ICollectionView to do this if you wish. Check my article on it :
http://www.abhisheksur.com/2010/08/woring-with-icollectionviewsource-in.html[^]
Abhishek Sur
Don't forget to click "Good Answer" if you like this Solution. Visit My Website-->www.abhisheksur.com
|
|
|
|
|
I have a question:
How to get client rectangle of a WPF window? I have tried using windows API GetClientRect, but it does not work and always return left=0, top=0.
I'm very appreciated if you can help me.
Thanks,
huy
|
|
|
|
|
One way to do it is to use VisualTreeHelper.GetDescendantBounds on the root element in the window.
|
|
|
|
|
Hi ,
I need to acheive List View Scrolling with MVVM. As iam new to MVVM Can u please let me know how it can be acheived . Can anyone please provide a sample for the same if possible.
Thanks
Krish
|
|
|
|
|
Listview scrolling in general has nothing to do with MVVM and is an inherent property of the control.
Could you please give more details so we can understand your question better?
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
I need to scroll the listview on a button click. Iam following MVVM pattern. I tried the following but it is not working.
<local:SortableListView x:Name="headLinesGridView" IsSynchronizedWithCurrentItem="True" Style="{DynamicResource ListViewStyle}" ScrollViewer.VerticalScrollBarVisibility="Hidden"<br />
ItemsSource="{Binding Source={StaticResource TestDataSource}}" ItemContainerStyle="{StaticResource headLinesGridViewStyle}"<br />
ColumnHeaderSortedAscendingTemplate="HeaderTemplateArrowUp" ColumnHeaderSortedDescendingTemplate="HeaderTemplateArrowDown" ColumnHeaderNotSortedTemplate="HeaderTemplateTransparent"><br />
<ListView.View> <br />
<GridView ColumnHeaderContainerStyle="{StaticResource gridViewHeaderStyle}" ColumnHeaderTemplate="{StaticResource HeaderTemplateTransparent}"><br />
<local:SortableGridViewColumn Header="ID" DisplayMemberBinding="{Binding ID}" SortPropertyName="ID" Width="50" /><br />
<local:SortableGridViewColumn Header="First Name" DisplayMemberBinding="{Binding FirstName}" SortPropertyName="FirstName" IsDefaultSortColumn="True"/><br />
<local:SortableGridViewColumn Header="Last Name" DisplayMemberBinding="{Binding LastName}" SortPropertyName="LastName" /><br />
<local:SortableGridViewColumn Header="Date of Birth" DisplayMemberBinding="{Binding DateOfBirth}" SortPropertyName="DateOfBirth" /><br />
<local:SortableGridViewColumn Header="QueueStatus" SortPropertyName="QueueStatus" IsDefaultSortColumn="True" CellTemplate="{StaticResource IconCellTemplate}"/><br />
</GridView> <br />
</ListView.View><br />
<ListView.ItemsPanel><br />
<ItemsPanelTemplate><br />
<WrapPanel Orientation="Vertical"></WrapPanel><br />
</ItemsPanelTemplate><br />
</ListView.ItemsPanel><br />
</local:SortableListView> <br />
<Button Grid.Row="1" Command="ScrollBar.LineDownCommand" CommandTarget="{Binding ElementName = Test}">Scroll Down</Button>
|
|
|
|
|
This is a common mistake in MVVM, trying to do too much in the VM. As this line down operation has absolutely no bearing on the model, it's perfectly fine to do this in code behind the view; after all, you just want to move the scrollbar on a visual. Go for it.
|
|
|
|
|
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
Hey,
is there anyone how get experiences with this class. I try to use it, in a normal way like this:
ManagementObjectSearcher mang = new ManagementObjectSearcher("SELECT * FROM Win32_DiskDrive");
foreach (ManagementObject obj in mang.Get())
{
MessageBox.Show(Convert.ToString(obj["Description"]));
}
Here, i used the DiskDrive-Class, and all work fine, but if i try to use the PhysicalMediaClass in the equal way, the output just gives me a zero-string.
what´s my mistake?? can anyone help me???
holzmcgyver
|
|
|
|
|
holzmcgyver wrote: what´s my mistake??
Well, for a start, this is the Silverlight/WPF forum.
holzmcgyver wrote: MessageBox.Show(Convert.ToString(obj["Description"]));
Does Description exist in the collection? Try Tag instead.
|
|
|
|
|
I recently started the WPF and I came across a weird behavior in listboxes.
I have it binding to a viewmodel object and displaying the view properly, even have it selecting the item properly.
Sometimes those listbox have text boxes for my user to type in, and when they hit the F key, it moves to the next listbox item.
After alot of digging I found out that it has to do with the name space of the item bound to the listbox. If I change the viewmodels class to "zsomename.folder.viewmodel" then when I type z in the text box it moves it to the next listbox item.
Its like there's a built in behavior to select a matching listbox item base off the starting letter... but how do I remove this, or what is calling this.
Anyone have any ideas?
|
|
|
|
|
That sounds weird. Can you paste a small code example here so we can reproduce this?
|
|
|
|
|
There is indeed built in behaviour to do this - however, your textbox shouldn't invoke this, are you using a datatemplate?
Can you please post the XAML that creates the listbox and its items? I'm sure we can help out
By the way the zsomename.folder.viewmodel is indeed why Z is selecting an item, however, if the keydown event in the textbox is bubbling then this needs to be address (bubbling events are those that at a point in the logical tree and move up).
|
|
|
|
|
Well it came up because we have a list box inside a listbox.
I was trying to make it so that when the user presses a letter "a,b,c,d,e,f... etc" it would select that given listbox subitem. Instead it move to the next question.
So this is happening in the key down event and I need to handle it there? Or is there a better way of doing it?
|
|
|
|
|
I think what you are looking for is TemplateBinding . See here[^].
The funniest thing about this particular signature is that by the time you realise it doesn't say anything it's too late to stop reading it.
My latest tip/trick
Visit the Hindi forum here.
|
|
|
|
|
Hi
I want to generate decimal point automatically while entering in textbox of wpf. Like the decimal point automatically generated while entering amount in ATM machine.
Please help thanks in advance.
|
|
|
|