mvvm

Collapse all the expanders and expand one of them by default

佐手、 提交于 2021-02-07 07:14:43
问题 I have multiple expanders, and I was looking for a way to collapse all others the expanders when one of them is expanded. And I found this solution here XAML: <StackPanel Name="StackPanel1"> <StackPanel.Resources> <local:ExpanderToBooleanConverter x:Key="ExpanderToBooleanConverter" /> </StackPanel.Resources> <Expander Header="Expander 1" IsExpanded="{Binding SelectedExpander, Mode=TwoWay, Converter={StaticResource ExpanderToBooleanConverter}, ConverterParameter=1}"> <TextBlock>Expander 1<

Collapse all the expanders and expand one of them by default

泪湿孤枕 提交于 2021-02-07 07:13:28
问题 I have multiple expanders, and I was looking for a way to collapse all others the expanders when one of them is expanded. And I found this solution here XAML: <StackPanel Name="StackPanel1"> <StackPanel.Resources> <local:ExpanderToBooleanConverter x:Key="ExpanderToBooleanConverter" /> </StackPanel.Resources> <Expander Header="Expander 1" IsExpanded="{Binding SelectedExpander, Mode=TwoWay, Converter={StaticResource ExpanderToBooleanConverter}, ConverterParameter=1}"> <TextBlock>Expander 1<

Caliburn ShowDialog and MessageBox

浪子不回头ぞ 提交于 2021-02-06 12:46:25
问题 I'm making a small demo application for MVVM with caliburn. Now I want to show a MessageBox , but the MVVM way. For dialogs I created an event, that is handled in the ShellView (the root view) and just calls WindowManager.ShowDialog with a Dialogs ViewModel type. Seems to stick to MVVM for me. But what is the way to show a messagebox and get its result (Okay or cancel)? I already saw this question, but it contains no answer either. Mr Eisenberg hisself answers with "Caliburn has services

WPF Step By Step 系列

孤者浪人 提交于 2021-02-06 09:18:44
公司最近要去我去整理出一个完整的WPF培训的教程,我刚好将自己学习WPF的过程和经验总结整理成笔记的方式来讲述,这里就不按照书上面的东西来说了,书本上一般都是按部就班,深入浅出。我这里主要是以实战和具体的代码为准来讲述。 目前使用WPF的时间不算长,大概有2年多,比园子里很多的大师,还是会差很多。现在才刚刚算是对WPF基本的应用时掌握了,但是距离UI设计方面,还是有很大的欠缺。由于本人不太擅长美感的东西。 WPF参考书推荐 下面先整理下,本人主要学习的WPF参考书: 1、WPF编程宝典(C#2010) 该书:( 必读 ) 心得体会:读完该书后,你对WPF的基础和基本控件的使用,包括WPF的编程模型,相比Winform的特性和如何开始在实际的项目中下手,都有了基本的认知。里面还介绍了控件模板的使用,WPF必须掌握模板。里面包含了WPF的方方面面,不过,深度还有待继续挖掘。 2、深入浅出WPF 该书 ( 入门必读 ) 心得体会:该书写的浅显易懂,特别适合对WPF不了解,又渴望快速对WPF上手的书,符合中国人的阅读习惯,很容易就看完该书,不过,该书中没有包含太多的结合项目实例的内容。是本好书。 3、WPF Programmer's Reference: Windows Presentation Foundation with C# 2010 and .NET 4 该书:(建议阅读)

Good way to refresh databinding on all properties of a ViewModel when Model changes

只谈情不闲聊 提交于 2021-02-05 13:03:45
问题 Short Version If I update the Model object that my ViewModel wraps, what's a good way to fire property-change notifications for all the model's properties that my ViewModel exposes? Detailed Version I'm developing a WPF client following the MVVM pattern, and am attempting to handle incoming updates, from a service, to data being displayed in my Views. When the client receives an update, the update appears in the form of a DTO which I use as a Model. If this model is an update to an existing

How do I bind to MasterPage viewmodel inside a BindableLayout

陌路散爱 提交于 2021-02-05 11:30:07
问题 I am trying to bind my Command property to the Command in my MasterDetailPage view model. I tried defining the name property for the master page and setting that as the reference source, but it does not seem to bind to the viewmodel. For context, the List MenuItems is a property in the same Viewmodel and the Title binds just fine. I believe I am not setting the Source for the command correctly, but not sure how to fix it. Also, I am using Prism, so the viewmodel is mapped in app.xaml already.

Cannot bind command within a ListBox

荒凉一梦 提交于 2021-02-05 10:48:05
问题 My WPF uses the MVVM approach. I'm trying to bind 2 controls within my list control <ListBox ItemsSource="{Binding ParentDuplicate}" SelectedItem="{Binding SelectedParent, UpdateSourceTrigger=PropertyChanged}"> <ListBox.ItemTemplate> <DataTemplate> <StackPanel> <ContentControl Content="{Binding}" /> <Button Content="Delete me now" Command="{Binding RelativeSource={RelativeSource Mode=FindAncestor, AncestorLevel=1, AncestorType=Window}, Path=DeleteCommand}" CommandParameter="{Binding FilePath}

WPF binding Listbox SelectedItem in ViewModel

南楼画角 提交于 2021-02-05 09:34:46
问题 I'm working on a WPF application. The main page is made up of a grid with 2 column and one row. on the first column i have a listbox and on the 2nd column i have a stackpanel named thePanel which i want to change on selected item of a listbox.i first implemented this in the View(mainwindow.xaml.cs) with the selectionChanged event of the Listbox and it worked. I tried to apply the MVVM so i had to do it in the viewModel. the Data Context of the mainwindow is set in its constructor and is of

Binding to properties in both the ViewModel and CodeBehind

核能气质少年 提交于 2021-02-05 07:51:30
问题 I have what I'm sure is a ridiculously ignorant question, but I'm asking it anyways because I've searched and searched and either don't understand the solutions I'm seeing or not finding exactly the answer I seek. I have an MVVM application. My XAML is setup with the DataContext set to the VM where the data items on the screen are populated from the VM's properties. My CodeBehind doesn't fiddle with the data, only things relating to the screen. What I want to do now is bind certain UI

Binding to properties in both the ViewModel and CodeBehind

五迷三道 提交于 2021-02-05 07:51:08
问题 I have what I'm sure is a ridiculously ignorant question, but I'm asking it anyways because I've searched and searched and either don't understand the solutions I'm seeing or not finding exactly the answer I seek. I have an MVVM application. My XAML is setup with the DataContext set to the VM where the data items on the screen are populated from the VM's properties. My CodeBehind doesn't fiddle with the data, only things relating to the screen. What I want to do now is bind certain UI