|
Check that the binding of the selecteditem in the combobox is Mode="TwoWay" .
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
hello guys... I am new to Silverlight. I am trying to create child windows in silverlight but when I try to access some of the methods shown online, those methods are not shows in intellisense. For example
namespace SampleGUIs
{
public partial class MainPage : UserControl
{
private ChildWindow cw;
public MainPage()
{
InitializeComponent();
cw = new ChildWindow();
cw.Closed += new EventHandler(ShowMessage);
}
}
}
I have included System.Windows and System.Windows.Control. Same is the case in ChildWindow.xaml. Some of the methods are not shown like
namespace SilverlightApplication9
{
public partial class PopupWindow : ChildWindow
{
public PopupWindow()
{
InitializeComponent();
this.Title = "Child Window";
}
}
}
what can be the problem? thnx
modified on Monday, June 27, 2011 7:15 AM
|
|
|
|
|
Seems rather obvious, ChildWindow does not have a Title Property whereas UserControl does. It all comes down to what you are deriving your view from.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Thanx for your answer. It certainly has Title property. I have just solved it. May be I was putting the code in wrong places. But now its working.
|
|
|
|
|
Hi All !
I using DataGrid in WPF and Using DataGrid.RowDetailsTemplate but i only click 1 row .How do I can click more that row in DataGrid?
You can Help me?
Thanks
|
|
|
|
|
There should me a SelectionMode (I think) that can be set to extended.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Using :
<dg:DataGrid AutoGenerateColumns="False"
SelectionMode="Extended"
ItemsSource="{Binding Source={StaticResource FlickrFeed}}"
RowDetailsVisibilityMode="VisibleWhenSelected">
<dg:DataGrid.RowDetailsTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" Margin="5">
<Image Source="{Binding XPath=media:thumbnail/@url}"
Width="60" Height="60"/>
<StackPanel Orientation="Vertical" Margin="5">
<TextBlock Foreground="CadetBlue" FontSize="20"
Width="400" TextWrapping="Wrap"
Text="{Binding XPath=media:category}"/>
</StackPanel>
</StackPanel>
</DataTemplate>
</dg:DataGrid.RowDetailsTemplate>
but only click a row.i want click more that row.
can you hepl me?
<dg:DataGrid.Columns>
<dg:DataGridTextColumn Header="Title"
Binding="{Binding XPath=title}" Width="150"/>
<dg:DataGridTextColumn Header="Published"
Binding="{Binding XPath=pubDate}"/>
<dg:DataGridTextColumn Header="Author"
Binding="{Binding XPath=media:credit}" Width="*"/>
</dg:DataGrid.Columns>
</dg:DataGrid>
</Grid>
|
|
|
|
|
tâzn wrote: but only click a row.i want click more that row.
hold the <shift> or <ctrl> key when you click the second row
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
lets say I have something like this in XAML:
<GridViewColumnCollection x:Key="Foo">
<GridViewColumn ... />
<GridViewColumn ... />
<GridViewColumn ... />
</GridViewColumnCollection>
if I do FindResource("Foo"), I get a GridViewColumnCollection, no problemo.
However, I'm using docking windows, and in a lot of situations, multiple windows share the same exact instance of MyUserCtrl.xaml and so they share the same exact instance of GridViewColumnCollection. This happens if I open multiple windows of the same type. Its a VisualTree optimization in docking windows.
So what happens is that if I resize a column in MyUserCtrl(instance 1), those values are shared across to MyUserCtrl(instance 2).
I could declare the GridViewColumns in code, but setting up all the properties, bindings, etc. is a PITA.
Is there a way to say "give me a new instance of Foo?
GridViewColumnCollection unfortunately does not implement IClonable. GridViewColumnCollection and GridViewColumn are not serializable either, so I can't do that trick.
Doing a member wise copy seems like another PITA.
Surely there has to be a clever way to keep those columns defined in XAML and be able to copy them or get new instances?
|
|
|
|
|
Seems like it works if I break GridViewColumnCollection out into a seperate ResourceDictionary and just create new instances of that ResourceDictionary. Seems kinda cheezy though. If you have a better way, let me know.
|
|
|
|
|
You could use XamlReader[^] perhaps.
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Hmm... looked good on paper , but it wouldn't serialize my collection (of MyGridViewColumn : GridViewColumn items), because the class has some private members that aren't serializable. I tried marking them as NonSerialized, but XamlWriter still had a hissy fit.
|
|
|
|
|
Oh, I don't believe I saw the "My"s in your original post
Mark Salsbery
Microsoft MVP - Visual C++
|
|
|
|
|
Lol, this thing is fighting me every step of the way.
I thought I got it to work by breaking that GridViewColumnCollection out into a seperate ResourceDictionary and creating multiple instances of the ResourceDictionary... I do get new instances of the columns...
BUT...
1) GridView.Columns is not a DP and you can't bind to it...
2) You can't add a GridViewColumn to more then one GridViewColumnCollection or it throws an exception
So I have to copy the columns into an ObservableCollection<GridViewColumn>, then clear the original GridViewColumnCollection then add a DP to MyGridView that can be binded to.
I thought WPF & MVVM was supposed to simplify things
|
|
|
|
|
You can actually use classes like MemoryStream and BinaryFormatter to serialize this data. This would be cloning your initial object and making a copy of 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.
|
|
|
|
|
I am new to WPF, but I would like to know if someone can show me how to delete a row in one datagrid based upon a selection from another. The application uses C# and MVVM design pattern. Can anyone help?
Thanks
|
|
|
|
|
If your DataGrid utilizes the SelectedItem property as follows
<DataGrid ItemsSource="{Binding Path=mySource}" SelectedItem="{Binding Path=myItem, Mode=TwoWay}"/>
, you can get the selected row. Based on the columns in it, you can pick up the id and delete from the other grid.
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.
|
|
|
|
|
How would this work in MVVM? As the application has been built using this design pattern.
|
|
|
|
|
The view model should be bound to the datacontext, so the SelectedItem property should get 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.
|
|
|
|
|
I would use linq to identify the record to be deleted and then remove it from the list
classname Instance = Listname.Where(x=>x.Field = Criteria).FirstOrDefault();
if(Instance !=Null)
{ListName.Remove(Instance);}
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
How would this work in MVVM? As the application has been built using this design pattern.
|
|
|
|
|
Member 2972992 wrote: As the application has been built using this design pattern
This indicates it was not built by you and it seem you have limited exposure to MVVM or Silverlight. It is going to be a little difficult to explain in a forum post, you have a learning curve in front of you that is going to include at least 1 book!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I have a MVVM application that has a MainWindow.xaml that defines the main window. The main window has a ribbon control and a tabbed MDI interface similiar to Visual Studio. The tabs are implemented in UserControl.xaml. So, obviously, I can have a bunch of UserControl instances.
Now, I want to add a button to the ribbon, but the button is going to operate on the active UserControl.xaml view model.
So the question is what is the best way to wire that up?
I have a few ideas, but they all seem bad.
1) have a static command class that defines the ICommands and somehow map that into the command bindings of the view and redirect into the VM. Not really sure how all that is going to wire up.
2) have UserControlVM expose a static command that takes an instance as the param and have MainWindow.xaml bind the button to that static command and pass in the active window.
Any other ideas?
|
|
|
|
|
You're gonna love this. Fellow WPF Disciple, Kent Boogaart, has created a command system for just such an eventuality. It's called the ActiveAwareCommand[^] and it's very cool.
|
|
|
|
|
Thanks, I'll take a look.
|
|
|
|