@Kevin no, that's a treeview, it's for an FAQ style thing where the Question is the top node in bigger text with an arrow on one side or the other, and when the header or arrow gets clicked, the arrow rotates to some degree via animation and then the smaller text/sub text gets faded in or animates in from a direction
Anyway, I have this exact error message as desribed at http://blogs.msdn.com/b/mikehillberg/archive/2006/09/26/cannotanimateimmutableobjectinstance.aspx "Cannot animate '...' on an immutable object instance" and I think that tip there is the way to go.
It worked all right for months, but other recent changes to the XAML make it happed so that the when the binding to SomeProperty, I very likely get that error message. Not always, but usually.
@franssu I suppose that doesn't hint on how to add a ValueConverter. Or then I'm too ignorant to understand it. :)
Which is something new, I perhaps have better luck with this. Part of the problem here is, it might have been good to tell in the first place, is that this is defined inside a template like this:
@franssu I'm looking for this now. I'm not sure (XAML is not my fortes). I see it's not inside this template and its `Border.Style`. In that `snip, snip...` there is
<ControlTemplate TargetType="ListBoxItem">
<Border x:Name="TabBorder" SnapsToDevicePixels="true">
<Border.Background>
<MultiBinding Converter="{StaticResource XyzTabBackgroundConverter}">
Could that be such a Place?
There's also another multibinding converter after that for <Border.BorderBrush>.
I'd paste more code, but it looks like I can't get it formatted properly...
@franssu Still `InvalidOperationException`. The exception message is in Finnish (I should change language to English, I see -- a new work comp), but it's something like "not all property Background.Color cannot objects can be referenced" or something. Maybe it means the default background is now null and it might needs to be set. Regardless of that, the color should be set too. I modified a bit the template (to protect the innocent, so to speak) and it's like this
Mm, this looks like getting somewhat difficult. Though, @franssu, you've given helpful insight already. I don't want to take too much your time on this. :)
@JohanLarsson It's part of a template for a list of tabs a background of which I'd like to blink. Unfortunately the template and all is somewhat complicated. :/
I've put a TextBlock in a 3D panel (Planerator) and I used a Storyboard to animate it. (as crawl text)
When the field of view is 1 everything works fine, But if I set the field of view to more than 5 the frame rate will drop sharply.
ُُI used theCompositionTarget.rendering.
Please see the foll...
@JohanLarsson Thanks. You are the man of last resorts! :D
Naturally I provide the credits to you if I end up using this. Which I may do, since if I need to take drastic measures and do rewriting with regard to this, you have the five litre XAML brain. :-P
Hmm. If, when profiling my app, I see that 51% of execution time takes place in System.Windows.Application.Run(), this probably means my bindings are slow and messed up, huh?
I'm not talking about broken bindings, necessarily.
I've filtered out most UI Virtualization problems where a lot of time was spent dozens of items that aren't even seen on-screen.
But I still have a lot of rendering that happens on app startup, causing the login to take 10-20 seconds, because we instantiate all the views and viewmodels in advance.
I've started implementing data virtualization as well, paging, to avoid fetching too many items and creating VMs for them, even if UI virtualization prevents actual rendering.
public class ViewModel
{
public ViewModel()
{
var ints = new ObservableCollection<int>();
IntsView = ints.AsDispatchingView();
}
public IObservableCollection<int> IntsView { get; }
}
looks like ^ (pseudo)
then the raw collection can be updated from other threads
@JohanLarsson We had a similar construction in a previous project - an ObservableList<T> that held two internal synchronized collections - a threadsafe List<T> and an ObservableCollection<T>, allowing it to be bound to like an ObservableCollection, but can accept Add/Remove requests from any thread.
Hi, I have a grid with a lot of columns in XAML, and it's really messy in the code (just 17 <ColumnDefinitions/> and then 17 buttons, one in each column), and I was wondering if there is a way to condense it or make all the columns in one line in the xaml code.
because now I have to do the same thing with a lot more buttons
Just using a dispatching OC won't necessarily solve my problems. I'll be able to create my VMs on a background thread, but it will still have to dispatch to the main thread to do its work.
@JohanLarsson I'm actually of the impression that default await/async always return on the original context (which is why we have to append .ConfigureAwait(false) to make it not marshal back on ui thread) -- is that what you said too in just different words?
I have a List<Customer> which is shown on View A and can be edited (add/remove items with a repository) on View B. Each view has its own ViewModel. When a change to the list is made in ViewModel B, I want ViewModel A to know about it so it can update the list also.
I've been using an event in the repository class (repository singleton instance used by both ViewModels) to notify ViewModel A of the change so it can refresh the list. I've just been introduced to messaging which seems fairly similar but limits the communication to only the ViewModels. Is messaging a better approach?
@SeeSharpCode sounds like somebody has been using frameworks for aid :)
Messaging shouldn't technically be limited to viewmodels, you can message from anywhere to anywhere (see stuff like MassTransit / ServiceBus / MessageBus / EasyMQ)
You are atop the west wall of a great canyon, offering a marvelous view of the mighty Frigid River below. Across the canyon, the walls of the White Cliffs join the mighty ramparts of the Flathead Mountains. To the north, … Continue reading →
@JohanLarsson One question I have with that is where to instantiate the list and pass it around. I instantiate my ViewModels in XAML. I'm guessing that would need to move to the code-behind so the parent ViewModel constructors could take the child as a parameter?
Hmmmm, one other hole to plug, perhaps. The list isn't actually updated manually, i.e. not an ObservableCollection. It is just refreshed when the repository tells the ViewModel something has changed. Should I still just use the event raised by the repository and subscribe the child ViewModel list to it now?
@Julien I really didn't see the point of using an OC. I could manually add/remove items from the OC, or I could call RaisePropertyChanged for both an add/remove which I saw as less code. I didn't see the point of using OC in the latter case since List would act the same way.
@Julien Perhaps my design is broken further upstream. I'm using a small dataset, so my repository grabs the data from an XML file. When something is added to the list, it calls the repository.Add(Customer). In repository.Add(), it fires RaiseRepositoryChanged which the ViewModel listens to and refreshes the list by calling repository.GetAll().
@Julien My List<Customer> in the ViewModel just has a getter that calls repository.GetAll(Customer). So the RaisePropertyChanged reads everything fresh from the repository.
@Julien So you think either approach would work between rebuilding the list vs. replicating the repository event on the OC? I just went with the first option as it seemed like less code.
@Julien Ok, so the repository might fire an event like this: RaiseRepositoryChanged(RepositoryEvent.Added/Removed, Customer customer), and then the OC would add/remove based on that?
@Johan In practice, it's often nice for line,ray,segment to be implemented almost identically, though - the only real difference is distance calcs and such
@Alex That's not in the framework - my sample project (not sure if it's still around) has an implementation, though tere's a better one in a gist in the links here (starred)