|
Sorry, I should have got back to you yesterday. The simplest way of doing this is have a property in the main VM that holds the collection that returns whether or not any are checked, and then use a combination of a lambda check and a property notification to update this. Basically, what you do here is catch the property changed notification from the items in the observable collection and if it's the checked property, you do a quick select count where the checked is true. If the count is greater than zero, you display the border.
|
|
|
|
|
I am not entirely sure what you mean. I think I have been looking at this for too long and nothing makes sense anymore.
|
|
|
|
|
I'll see about knocking up a blog post later on for you that demonstrates this.
|
|
|
|
|
Rather more than I was hoping for but it would be much appreciated. As I said, I have spent that long looking at this now that nothing seems to make much sense.
|
|
|
|
|
I haven't had a chance to knock a blog post together on this, but if you'd like to send me your email address (via the email link here) I'll send you a working sample.
|
|
|
|
|
Other than what Pete suggested, another method is to create your own Collection which inherits from ObservableCollection, and put a Property on that that you bind to for data validatation, then you set the DataContext of your ListBox to the collection, bind right to it for ItemsSource, and bind to your custom boolean for the datavalidation part
|
|
|
|
|
What do I bind to the custom boolean?
|
|
|
|
|
Hi,
I am using silverlight 4 in vs 2010
I have created a solution with the following projects.
Web project to host the silverlight app
Silverlight project with silverlight pages.
wcf project.
All compiles.
I have added the wcf as service references to the silverlight application.
There is a clientaccesspolicy.xml folder inside the wcf project
Do you see why the following error occurs please?
Thanks
The error I get is:
CommunicationException was unhandled by user code
The remote server returned an error: NotFound.
This is the code in the silverlight page:
private void UserControl_Loaded(object sender, RoutedEventArgs e)
{
myService.myClient client = new myService.myClient();
client.GetAllDataCompleted += new EventHandler<myService.GetAllDataCompletedEventArgs>(client_GetAlldataCompleted);
client.GetAlldataAsync();
}
private void client_GetAllDataCompleted(object sender, myService.GetAllDataCompletedEventArgs e)
{
grid.DataContext = e.Result;
}
|
|
|
|
|
Have you got the service URL correctly confugured?
Check the config file.
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.
|
|
|
|
|
Which config file do you mean?
web.config in the WCF ?
How do I know it is properly configured?
Thanks
|
|
|
|
|
No the config file on the client side - serviceclient.config.
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.
|
|
|
|
|
One tool I always find useful in diagnosing any network application, is wireshark.
With this, you can see what exactly the client is asking for, and what exactly is being returned...
Once you know whats going on 'over the wire' you can work back through your code & configuration to figure out what the problem is...
|
|
|
|
|
I have an expander control that contains search fields, the idea being that when the user wants to filter records they press the filter button the expander control lightboxes the screen so the user can choose from drop downs and then press search. When the user presses the search button, I want the expander to collapse, this is about what it all looks like:
XAML for expander:
<Expander
HorizontalAlignment="Left"
ExpandDirection="Right"
IsExpanded="{Binding IsExpanded, Mode=OneWay}"
Style="{StaticResource sbExpander}">
Viewmodel:
public bool IsExpanded { get; private set; }
private void Search()
{
...<other code is here>
IsExpanded = false;
OnPropertyChanged("IsExpanded");
}
Is there any reason this should not work? On the loading of the window the IsExpanded = false works correctly, but the search triggering the IsExpanded = false does not work. Thoughts?
Cheers and Merry Christmas, --EA
|
|
|
|
|
Generally, the way you would set this up to ensure that the binding ALWAYS stays synchronized, would be a TwoWay binding with a property like this:
private bool _isExpanded = false;
public bool IsExpanded {
get { return _isExpanded; }
set { _isExpanded = value; OnPropertyChanged("IsExpanded"); }
}
The underscore prefix is just how I usually do private variables... And if you want it to be more efficient, you can have the setter first make sure the value is actually changing...
But anyway, if you set up the property like that, you really never have to worry about, say, forgetting to do an OnPropertyChanged notification.
That said, I don't see anything wrong in the code you posted, from a functionality standpoint. The problem might be elsewhere. If you're replacing the template in sbExpander, that might be a potential trouble spot.
|
|
|
|
|
Thank you. I was trying to take a shortcut in the declaration of the public IsExpanded property. By not using a backing property and using private set, I disallowed the two way binding.
I fixed it as per your suggestion:
XAML:
<Expander
HorizontalAlignment="Left"
ExpandDirection="Right"
IsExpanded="{Binding IsExpanded}"
Style="{StaticResource sbExpander}">
ViewModel:
public bool IsExpanded
{
get { return _isExpanded; }
set
{
if (value == _isExpanded)
return;
_isExpanded = value;
OnPropertyChanged("IsExpanded");
}
}
Thanks for the insight.
Cheers, --EA
|
|
|
|
|
I would like to use the navigation controls that utilize the journal history of pages that are navigated to. I know normally I have to have the page navigated to first to enable the forward arrow because it needs a history or journal entry. Is it possible to load four pages at start-up so you can use the forward navigation button without actually navigating to those pages? The reason for this is I would like to not have to create additional buttons for forward or back navigation.
My uses are a WPF wizard using PageFunctions as each page. The start-up class is of type NavigationWindow but always displays page 1 after start up. In other words there is no "launching" dialog as is found in many WPF wizard uses..
Thanks in advance.
|
|
|
|
|
I am using <navigation:Page for my silverlight pages.
Where do I place the resources on this page?
I have used usercontrols before and used to place the <usercontrol.Resources> inside the usercontrol page.
But not sure where to place the resources if I use navigation pages. These navigation pages are created using silverlight page items in silverlight 4
Any thoughts please?
thanks
|
|
|
|
|
Hhi,
In the following xaml, you see that I am showing the Address field when a row of datagrid is clicked on.
Question:
I have a datagrid2 which I would like to be placed instead of the Address field.
At present I am using the event:
datagrid1_RowDetailsVisibilityChanged to populate datagrid2 for the selected row in datagrid1
How do I replace the address field with the datagrid2 please? Can I place something like <datagrid2></datagrid2> instead of the <TextBlock Text="{}"... ?
Thanks
<data:DataGrid.RowDetailsTemplate>
<DataTemplate>
<Border>
<Border>
<TextBlock Text="{Binding Address}" TextWrapping="Wrap"></TextBlock>
</Border>
</Border>
</DataTemplate>
</data:DataGrid.RowDetailsTemplate>
|
|
|
|
|
This[^] may 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.
|
|
|
|
|
Not sure what you are referring to.
Please explain.
|
|
|
|
|
Are you not looking for a datagrid within a datagrid?
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.
|
|
|
|
|
|
If not, then I have misunderstood your question.
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.
|
|
|
|
|
If I have a dynamically created OdbcDataReader, how do I hook it to the ListView in order to display the contents?
I already have the columns defined, and I just want to display the records from the data reader.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|
|
I figured it out:
Set the ListView.ItemsSource to the DataReader, and in XAML, set the Binding Path property of each column to its associated database field name.
The difficult we do right away...
...the impossible takes slightly longer.
|
|
|
|