|
Yeah, thats what I was getting at... according to your screen shot, the ListBox ItemsSource should be binding to the list of items that looks something like:
[0] A7136-67001 _ System BRX...
[1] AB587-60005 _ ...
.
.
.
The ItemsSource for the ItemsControl should be binding to a collection that looks something like:
[0] Leveling pad - screws into bottom of cabinet
[1] Backplane
.
.
Are the radio buttons choices going to be the same for each ListBoxItem? If so, you can just use a single ItemsSource for all the radio buttons and have that List on your VM. Otherwise, each item would need to have its own list of RadioButton choices.
|
|
|
|
|
There will always be 3 radio buttons. Their content is coming from data.
Everything makes sense in someone's mind
|
|
|
|
|
Ok, I see...
So, in this XAML
<Window.Resources>
<HierarchicalDataTemplate DataType="{x:Type model:PartDescriptionUpdateModel}"
ItemsSource="{Binding Path=Descriptions}">
<StackPanel Orientation="Vertical">
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Path=PartNo}"/>
<Label Content=" - "/>
<TextBlock Text="{Binding Path=Description}"/>
</StackPanel>
<ItemsControl ItemsSource="{Binding Descriptions}"
Margin="10, 0, 0, 20">
<ItemsControl.ItemTemplate>
<DataTemplate>
<RadioButton Content="{Binding PartDescription}"/>
</DataTemplate>
</ItemsControl.ItemTemplate>
</ItemsControl>
</StackPanel>
</HierarchicalDataTemplate>
</Window.Resources>
I think it's as you described... The LisBox is bound to a list of PartDescriptionUpdateModels. They have the PartNumber and Description.
The ItemsControl is bound to Descriptions, wich is the subitems list on the PartDescriptionUpdateModel. Still, the ItemsControl feels wrong.
Everything makes sense in someone's mind
|
|
|
|
|
Ok, so the ListBox is bound to some object that has a "List<partdescriptionupdatemodels> Descriptions" property. Everything inside of the data template is bound to a SINGLE PartDescriptionUpdateModels in that list. So then it makes sense why both are binding to "Descriptions" because those are two different "Descriptions". It looks like your XAML is correct except the 2nd Descriptions object only contains the one item (the ...screws to bottom of case... item)? Can you debug that and see if you really have the 3 items in that list?
|
|
|
|
|
THANK YOU!
I did indeed have some issues in the code behind. Strange thing is, I worked on this last night and the collections were correct. After your last post I thought, "I better check just to be sure", and of course not only was the data wrong, but I had a couple of subtle bugs that were affecting it.
So, now I have this[^].
Next step is to wire up the IsSelected.
Again, many thanks!
Everything makes sense in someone's mind
|
|
|
|
|
Cool. I think if you try clicking around on the radio buttons, you'll find they operate like checkboxes. Adding in the GroupName as I mentioned before will fix that.
|
|
|
|
|
Ya I think that I will add a GroupName property to the PartDescriptionModel. Then I will set all 3 to a unique value when I'm loading the collection. Then bind the GroupName to that property. That ought to do it.
Everything makes sense in someone's mind
|
|
|
|
|
Hey all,
I am working on some code for Silverlight / windows phone:
I have 2 Xaml pages , Main and Second page:
Main page , I have a button. With default text. " button"
I have an OnHold event, that navigates to Second.xaml page.
On Second.xaml page is a ListBox. With lets say 3 ListBoxItems. item1, item2 and item3.
Here's where I am lost.
I want to have my selected item() 1 2 or 3, do 2 things:
1. Update the text in the button on the MainPage.xaml. The text says "item1" or whateveritem I selected.
2. The selected item in the listbox also selects an object in a folder. Call this folder resources. and the objects lets say are text or png files or whatever...just something I created outside of the IDE.
I wil worry about any OnClick functions or what to do with the objects in the folder later. Its the selection / update upon multiple pages that gets me right now.
|
|
|
|
|
You mean auto select a file / folder in an external Windows Explorer window?
You can just do something like:
System.Diagnostics.Process.Start("explorer.exe", avi.Path);
and it will auto-select the folder / file in avi.Path for you.
Does Main have a reference to Second? or does Second have a reference to Main? Really, in proper MVVM, they shouldn't know about each other, so you should use something like a messenger service to communicate between views.
|
|
|
|
|
Well actually I think simpler than that?
this is strictly going to be a windows phone application using a couple xaml pages. No windows.exe or anything like that.
so no mesenger service either as navigating from one xaml to another in a windows phone app is normal and accepted.
|
|
|
|
|
Do you have a reference to the other page? You could just subscribe to a simple event.
|
|
|
|
|
A reference? Well the only reference I have in a snece is the button OnHold event navigationg to the second page.
|
|
|
|
|
Hmm.. well, I'll have to hand you off to the Silverlight guys then. If you don't have a reference to the page and don't want to use messenger (which is really simple IMO), then I'd think you'd need a global static class that exposes an event or holds the references there. There might be something to handle that in Silverlight that I'm not aware of. In WPF, I'd certainly use messenger to communicate between views.
|
|
|
|
|
Hi, I'm drawing on a topmost semitransparent Window. I'd draw rectangle with transparent background.
I tried:
rec.Fill = new SolidColorBrush(Color.FromArgb(0, 255, 255, 255));
canvas.Children.Add(rec);
but doesn't work. How can I do?
|
|
|
|
|
I know how to create a flat style button with just the image showing unless the user hovers over it or when it's pressed. I don't know how to do the same thing for a toggle button. I need it be flat (image only) in a normal state but when the user hovers over it or when it is pressed or when IsChecked=True the state behaves like the default toggle button. I tried modifying the Normal state only but when I do, the MouseOver state no longer behaves the same way.
Any ideas?
Let me know,
Aaron
|
|
|
|
|
Hi,
I have a Silverlight application where in the browser which loads a WCFClient dll requests the data from a server a WCFService dll.The IE has many graphic elements on the browser window which are populated with the data retrieved from the WCFService. The issue here is the server is throwing the below exception when the the number of graphic elements configured exceeds.Also the data is not populated in these graphic elements.
[HttpWebRequest_WebException_RemoteServer]
Arguments: NotFound
Debugging resource strings are unavailable...
Going through the below blog
http://forums.silverlight.net/t/133801.aspx/3/10[^]
observed that the issue could be with the following tag configured in my WCFService projects Web.config file
<dataContractSerializer maxItemsInObjectGraph="2000000000"/>
Could any one of you please tell me how to go about fixing this issue?
Thanks
Satya
Today is a gift, that's why it is called the present.
|
|
|
|
|
Hi all, I've a transparent topmost window, I need on mouse move to highlight the window under the cursor
I tried so in mouse_move_handler:
...
this.Hide();
hWnd = Win32.WindowFromPoint(p);
this.Show();
...
Win32.GetWindowRect(hWnd, ref rc);
and so on drawing rectangle
...
this code works, but I can't avoid flicker.
There is some alternative way to do this?
|
|
|
|
|
I'm not surprised you've got flickering. You keep showing and hiding a window in there, and it looks as though you are calling this on every mouse move - that's a lot of event updates you're calling this code in. You also haven't shown the code where you're highlighting, this will also be called a lot of times.
What is the purpose of the Hide/Show code? What are you changing the visibility of?
Are you tracking to see if the window that was last updated matches the one retrieved in WindowFromPoint? If not, that's an obvious optimisation.
|
|
|
|
|
The main problem is to get the hwnd of the window immediately under my wpf topmost Window.
|
|
|
|
|
To be honest, I'm not sure why you're dropping down to GDI to achieve this. There are ways to get the positions of windows that do not rely on dropping down to interop to retrieve these items. You can use the Visual tree and perform your calculations based off that.
|
|
|
|
|
because with visual tree I can handle only the windows that own to my application, but under the mouse cursor there may be a window of any application running on desktop.
|
|
|
|
|
Ah, I see. So you're evaluating ALL windows then.
Well, you're going to have to optimise your hit tests then I'm afraid.
|
|
|
|
|
I don't know how perform hit test without hiding my window...
|
|
|
|
|
Probably the easiest way to code this is to enumerate all the windows using EnumDesktopWindows[^]. You can use this to iterate over and do your point in rectangle tests. That way, you aren't relying on showing/hiding windows.
|
|
|
|
|
I use EnumWindows, the problem is that more than one windows pass the check(point in rect). How can I determine the right window on which lies the mouse?
|
|
|
|