 |
 | Bizarre - setting the selected index in a listbox removes the item |  | Christian Graus | 3hrs 54mins ago |
|
 |
So, I have an ObservableCollection as the datasource for a listbox. Now when I change the collection, the control updates itself. However, the problem that I was focused on, remains.
string item = playlists.SelectedItem as string;
if (!string.IsNullOrEmpty(item)) { int index = playlists.SelectedIndex;
if (index < _playlist.Files.Count - 1) { _playlist.Files[index] = _playlist.Files[index + 1]; _playlist.Files[index + 1] = item;
// This REMOVES the item !! // playlists.SelectedIndex = index + 1;
If I don't set the selected index, the wrong item is highlighted ( that is, the one I just renamed ). If I try to set the other item to be selected, that item disappears from my control. The item is also removed from my collection. This looks like a major bug to me, is it behaving as adverised ? If so, how do I use the SelectedIndex property to set the selection, rather than remove an item ?
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
 |
|
 |
How do I go about editing items in a bound ListBox? I thought it would be as simple as binding a TextBox to the ListBox, but apparently, it's not.
I am creating a WPF window that displays a list of color names in a ListBox. The list comes from a property on the DataContext, to which the ListBox.ItemsSource property is bound. When I select a ListBox item, I want it to appear in a TextBox. Any changes I make in the TextBox should update the selected ListBox item.
Here's my XAML for the ListBox:
<ListBox x:Name="ListBoxColors" ItemsSource="{Binding ColorNames}" />
And here's my XAML for the TextBox, whose Text property is bound to the ListBox:
<TextBox Text="{Binding ElementName=ListBoxColors, Path=SelectedValue.Content, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
The ListBox binding works fine in both directions, but the TextBox binding only works in one direction--from the ListBox to the TextBox. Canges in the TextBox are not propagated back to the ListBox.
Here's my question: Can a TextBox Be bound to a bound ListBox in XAML, or do I have to go back to handling events in code-behind. If it can be done with XAML bindings, how? Thanks for your help.
David Veeneman www.veeneman.com
|
|
|
|
 |
 | Postbuild script for allowing usage of WCF [modified] |  | ezazazel | 8hrs 8mins ago |
|
 |
Hi!
Does anyone know how a postbuild batch (Setup Project) would look like to make wcf usable? I have to run my project as Administrator to get it working, but I once read that there would be a way of adding the port via a console command, so the application (WCF Service /ServiceHost) could run without admin-rights.
Help would be really appreciated!
ADDED: Found the command again: netsh http add urlacl url=htp://+8090/ user=<domain\user>
This should be executed as a postbuild / postinstall method where the domain\user should be current domain and current user
Would this work on a xp-machine as well?
eza
modified on Tuesday, March 24, 2009 5:04 PM
|
|
|
|
 |
|
 |
Is it possible to programatically turn the use of DataTemplates on/off on a control-by-control basis?
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
 |
|
 |
From what I remember you can apply them dynamically on a per-control basis so...
Are you looking for something other than that?
|
|
|
|
 |
|
 |
Well, I've defined them in the XAML (and I have yet to get it to work),but I only need them active at a certain point (when the user clicks a button).
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
 |
 | Databinding textbox to double |  | ErikZ | 13hrs 56mins ago |
|
 |
Hi,
I'm trying WPF and databinding....and I've run into a simple(I suppose) problem. Hopefully someone cam point me in the right direction. If I declare a double like this i window.resources:
<System:Double x:Key="myValue">10</System:Double>
How can I bind a textboxs textproperty to it?
|
|
|
|
 |
|
 |
Here's a sample:<Page xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:System="clr-namespace:System;assembly=mscorlib" > <Page.Resources> <System:Double x:Key="myValue">10</System:Double> </Page.Resources> <Grid> <TextBox Text="{Binding Source={StaticResource myValue}, Mode=OneWay}" /> </Grid> </Page>
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes. My blog | My articles | MoXAML PowerToys
|
|
|
|
 |
|
 |
Thank you very much, but how about TwoWay binding? Why doesnt that work? If I create a simple class and have a property of type double and bind to that property it works fine.
|
|
|
|
 |
|
 |
It won't work in this sample because you don't have a variable backer to bind into - it's a StaticResource. If you had a variable the two way binding would work.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes. My blog | My articles | MoXAML PowerToys
|
|
|
|
 |
|
 |
Hi, I want to know the Exact use and purpose of Windows Workflow Foundation? i gone through many articles, in that they explain their own examples only but no one describe about WF and WF uses.
Please Explain Purpose of WF.
Please dont give links, In that they explain with an example only.
Thanks In Advance. --Naren 
|
|
|
|
 |
|
 |
Like its bastard cousin (WPF), it's main purpose is to slow development to a crawl while you search in vain for answers to your inevitable questions. If and when you ever get your application finished, its secondary purpose kicks in, obfuscating the programs intended purpose and making maintenance more difficult because Microsoft abandoned the framework soon after introducing it (like they're doing to LINQ, and soon, WPF).
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
 |
|
 |
John Simmons / outlaw programmer wrote: because Microsoft abandoned the framework soon after introducing it (like they're doing to LINQ, and soon, WPF)
Where did you read that?
Kevin
|
|
|
|
 |
|
 |
I read a blog somewhere today that said Microsoft was pushing silverlight and would soon abandon WPF.
Don't ask me where, because I don't recall (and thought it was kind of absurd myself).
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
 |
|
 |
I know I don't have to state this, but I will anyway - Silverlight can't replace WPF - they aren't even the same "technologies".
So your frustrations with learning a new framework (which I bet you'll soon find much more flexible than Windows Forms) has led you to rehashing garbage you read on the internet?
Mark Salsbery Microsoft MVP - Visual C++
|
|
|
|
 |
|
 |
I tend to lash out at any moving object when I'm pissed off. 
Of course, I know that silverlight can't replace WPF, but we all know about Microsoft's tendency toward platform/framework/paradigm abandonment, so I figured I'd ping on it.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
 |
|
 |
Well, they almsot certainly won't be abandoning LINQ anytime soon. It's part of the core languages. Maybe you're thinking of Linq to SQL vs. Linq to Entities?
As for WF, it is being pushed out to more and more products. Whether anyone is using it or not is another matter.
However, WF and WCF are becoming more intertwined and the new Oslo modelling platform is heavy on WF. My impression is that WF is intended to be analogous to WPF/Silverlight in the following way.
WPF/Silverlight is intended to allow easier partition of work between developer and designer. WF is intended to allow easier partition of work between developer and business analyst.
There is an Oslo whitepaper that provides an illustration of this scenario.
Kevin
|
|
|
|
 |
|
|
 |
|
 |
Hi, I created one wpf application and published it. When i run it from another system thar doesn't have Dotnet framework installed, it show me an error(Prerequisite- dotnet framework 3.0 &Windows; installer). Any idea regarding this.
Gomathi R
|
|
|
|
 |
|
 |
You could deploy it using ClickOnce, which would download the relevant framework, or you could add the framework in as a required resource into the installer for your project, or you could supply the link for the user to download and install the framework.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes. My blog | My articles | MoXAML PowerToys
|
|
|
|
 |
|
 |
Install .net - I mean if it's a .net application then you're going to need .net installed
|
|
|
|
 |
|
 |
Dear All,
I am a newbie to WCF.
I have already implemented .Net remoting to communicate between the 2 .Net Windows Services in .Net Framwork 2.0
I want to use WCF for the same now in another project using .Net Framework 3.5.
Can any one guide or give me links related to article / sample for the same?
Thanks a lot in advance.
Best Regards, M. J. Jaya Chitra
modified on Tuesday, March 24, 2009 7:37 AM
|
|
|
|
 |
|
 |
If you're brand new to WCF one of the best intros is Michele Bustamante's online chapter 1 from her book Learning WCF[^]. She provides the source code as well.
This is also available in PDF format.
Kevin
|
|
|
|
 |
|
 |
I create a control in wpf that use treeview and pubulate node by code Now : the problem is when I drag the scroll it doesn't work but it work when i use the mouse scroll or when use the arrows of scroll
|
|
|
|
 |
|
 |
Thanks ABitSmart And Pete for your answers. I am trying to use RoutedEvent correctly this time. But the RoutingStrategy doesn't work.
MyButtonSimple class has a RoutedEvent which RoutingStrategy is Tunnel.
public class MyButtonSimple: Button { // Create a custom routed event by first registering a RoutedEventID // This event uses the bubbling routing strategy public static readonly RoutedEvent TapEvent = EventManager.RegisterRoutedEvent( "Tap", RoutingStrategy.Bubble, typeof(RoutedEventHandler), typeof(MyButtonSimple));
// Provide CLR accessors for the event public event RoutedEventHandler Tap { add { AddHandler(TapEvent, value); } remove { RemoveHandler(TapEvent, value); } } public MyButtonSimple() { this.Tap += new RoutedEventHandler(MyButtonSimple_Tap); }
//Handle the TapEvent void MyButtonSimple_Tap(object sender, RoutedEventArgs e) { Debug.WriteLine("Tag:"+this.Tag.ToString()); } }
Then I have a Window1 to test MyButtonSimple like this
<Window x:Class="WpfApplication1.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:WpfApplication1" Width="300" Height="300"> <local:MyButtonSimple Width="80" Height="80" Tag="OuterButton"> <Canvas Width="60" Height="60" PreviewMouseDown="Canvas_PreviewMouseDown"> <local:MyButtonSimple Width="20" Height="20" Tag="InnerButton"/> </Canvas> </local:MyButtonSimple> </Window>
private void Canvas_PreviewMouseDown(object sender, MouseButtonEventArgs e) { RoutedEventArgs newEventArgs = new RoutedEventArgs(MyButtonSimple.TagEvent); (sender as Canvas).RaiseEvent(newEventArgs); }
Well, just as my anticipation, the output window printed "OutterButton". But when I change the RoutingStrategy to RoutingStrategy.Tunnel, which I anticipate to raise the InnerButton ,the output window still printed "OutterButton". Is it against the routed mechanism? And Many ways I've tried since then(such as raise the event in Canvas_MouseDown), it still printed "OutterButton". And what I wanna see is "InnerButton". Am I doing wrong angain or the RoutingStrategy doesn't work this way?
|
|
|
|
 |