runceel / livet Goto Github PK
View Code? Open in Web Editor NEWWPF MVVM Infrastructure.
License: Other
WPF MVVM Infrastructure.
License: Other
CursorTypeAndBooleanConverter is not working.
Because, it should convert to string instead of CursorType.
private CursorType _convertWhenTrue;
public CursorType ConvertWhenTrue
{
get { return _convertWhenTrue; }
set
{
_convertWhenTrue = value;
_isConvertWhenTrueSet = true;
}
}
👇
private string _convertWhenTrue;
public string ConvertWhenTrue
{
get { return _convertWhenTrue; }
set
{
_convertWhenTrue = value;
_isConvertWhenTrueSet = true;
}
}
https://www.c-sharpcorner.com/forums/how-to-bind-wait-cursor-using-mvvm-in-wpf
I can write fix code and PR by hand.
But, this class is generated.
Sorry, I don't know T4 template.
Livet is for .NET Core 3.x now. And The Livet Extension is for Visual Studio 2019 now.
こんにちは、
また、困ったことがあるので、改めてご連絡いたします。
ViewModelAからViewModelBへメッセージを渡したいですが、Livetはこの行動をサポートしますか。
今、MVVM Light Messengerツールで渡されます。こういう感じです。
http://dotnetpattern.com/mvvm-light-messenger
例えば:ViewModelAからViewModelBへメッセージを渡す。
ViewModelAのコード
MessengerInstance.Send("ToViewModelC"); //「ToViewModelC」のメッセージを渡す。
ViewModelBのコード
MessengerInstance.Register<string>(this, message=>
{
if (message == "ToViewModelC")
{
// 習得されたmessageで操作する
}
});
ですが、Livetに変更してみたいです。このような行動はサポートがあるのですか。
ご指導のほどよろしくお願いいたします。
Livet 4.0.1 + .NET 6 + VS 2022 で FolderBrowserDialog を開こうとするとエラーが発生します。
Something errors were occurred.
Could not load file or assembly 'Microsoft.WindowsAPICodePack.Shell, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. 指定されたファイルが見つかりません。
ターゲットフレームワークを .NET 5 にするとエラーは発生しません。
テストプログラム:
https://github.com/shinta0806/TestFolderBrowserDialog
@runceel @karno @Gab-km @YoshihiroIto @ledsun
Hi,
My WPF (.Net framework) 4.5.2 application was using older version of LivetCask(2.2.0), that time it was working fine.
Now i updated the LivetCask into 3.2.1. When updating the latest package using Nuget, some other LivetCask components also installed.
The blow code shows error :
the value of type can not be added to a collection or dictionary of type triggeractioncollection for event trigger.
<i:Interaction.Triggers> <i:EventTrigger EventName="ContentRendered"> <l:LivetCallMethodAction MethodTarget="{Binding}" MethodName="Initialize"/> </i:EventTrigger> <i:EventTrigger EventName="Closed"> <l:DataContextDisposeAction/> </i:EventTrigger> <l:InteractionMessageTrigger Messenger="{Binding Path=Messenger}" MessageKey="ok"> <l:WindowInteractionMessageAction/> </l:InteractionMessageTrigger> <l:InteractionMessageTrigger Messenger="{Binding Path=Messenger}" MessageKey="cancel"> <l:WindowInteractionMessageAction/> </l:InteractionMessageTrigger> </i:Interaction.Triggers>
Please help me on this.
重大度レベル コード 説明 プロジェクト ファイル 行 抑制状態
エラー 参照を追加できませんでした。パッケージ 'LivetCask' はフレームワーク参照を 'Microsoft.Expression.Interactions' に追加しようとしましたが、GAC に見つかりませんでした。これは、パッケージのバグである可能性があります。パッケージの所有者にお問い合わせください。
参照を使用できません。
こんにちは。Nugetライブラリの更新方法が分かりませんので,お願いできませんでしょうか。お手数おかけします。
nugetの「プロジェクトURL」には,現在 http://ugaya40.hateblo.jp/entry/Livet が指定されていますが,ブログは2014年以来更新されておらず,「仮死状態の」プロジェクトに見えてしまいます。
GithubのプロジェクトページのURLに変更する方が良いのではないでしょうか。
WindowActionMessageのCreateInstanceCoreメソッドのオーバーライドにバグがあります。
return new WindowActionMessage(MessageKey);
となっていますが、正しくは
return new WindowActionMessage(Action, MessageKey);
のはずです。
こうしないと、ViewModelからWindowActionMessageをRaiseしたときに、渡したActionがウィンドウに正しく作用しません。
TestMethod(Super arg)
なメソッドを、Super
のサブクラスの型 Sub
を引数に呼び出すと ArgumentException
が発生します。
以下のコードを実行。
using System;
using Livet.Behaviors;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
TestNormal();
TestBinder();
}
private static void TestNormal()
{
// MethodBinderWithArgument を使わない通常の呼び出し
Super calleeArg = null;
var test = new Test(x => calleeArg = x);
var callerArg = new Sub();
test.TestMethod(callerArg);
Console.WriteLine(callerArg == calleeArg); // True
}
private static void TestBinder()
{
// MethodBinderWithArgument を使った呼び出し
Super calleeArg = null;
var test = new Test(x => calleeArg = x);
var binder = new MethodBinderWithArgument();
var callerArg = new Sub();
binder.Invoke(test, "TestMethod", callerArg); // ArgumentException となる
Console.WriteLine(callerArg == calleeArg);
}
}
class Test
{
private readonly Action action;
public Test(Action action)
{
this.action = action;
}
public void TestMethod(Super arg) => this.action?.Invoke(arg);
}
class Super { }
class Sub : Super { }
}
TestBinder()
の実行結果は TestNormal()
と同じとなる。
binder.Invoke()
にて ArgumentException
が発生する。
以下の部分で引数のキャスト可否判定に使用している IsAssignableFrom
の左右が逆と考えられます。
Visual Studio 2019 以降は WPF で Behavior を使う場合には基本的に以下のものを使うか System.Windows.Interactivity
が使いたい場合は Visual Studio 2017 から入れることになる。
https://github.com/Microsoft/XamlBehaviorsWpf
そのため、長期的にメンテナンスをしていくことを考えると既存の System.Windows.Interactivity
から、新しい XamlBehaviorsWpf
で提供されている Behavior に更新する必要がある。
代替案などがあれば、ここに書き込んでください。
権限付与ありがとうございました。
README.mdの「Working with Visual Studio and Livet」のセクションで,スクリーンショットのリンク切れです。過去のコミットから復活させれば良いのでしょうか?
Can you write some English document of this ... please thank you ...
LivetCask 3.2.3.2
LivetExtension 3.2.3.2
Both .NET3.1 and .NET Framework4.6.2
System.InvalidOperationException
HResult=0x80131509
Message=オブジェクト 'Livet.Messaging.IO.FolderSelectionMessage' は読み取り専用状態であるため、そのプロパティを設定できません。
Source=WindowsBase
スタック トレース:
at System.Windows.DependencyObject.SetValueCommon(DependencyProperty dp, Object value, PropertyMetadata metadata, Boolean coerceWithDeferredReference, Boolean coerceWithCurrentValue, OperationType operationType, Boolean isInternal)
at System.Windows.DependencyObject.SetValue(DependencyProperty dp, Object value)
at Livet.Messaging.IO.FolderSelectionMessage.set_SelectedPaths(String[] value)
at Livet.Behaviors.Messaging.IO.FolderBrowserDialogInteractionMessageAction.InvokeAction(InteractionMessage m)
at Livet.Behaviors.Messaging.InteractionMessageAction`1.Invoke(Object parameter)
at Microsoft.Xaml.Behaviors.TriggerAction.CallInvoke(Object parameter)
at Microsoft.Xaml.Behaviors.TriggerBase.InvokeActions(Object parameter)
at Livet.Behaviors.Messaging.InteractionMessageTrigger.<>c__DisplayClass21_0.<MessageReceived>b__1()
at Livet.Behaviors.Messaging.InteractionMessageTrigger.DoActionOnDispatcher(Action action)
at Livet.Behaviors.Messaging.InteractionMessageTrigger.MessageReceived(Object sender, InteractionMessageRaisedEventArgs e)
at Livet.EventListeners.WeakEvents.LivetWeakEventListener`2.ReceiveEvent(WeakReference`1 listenerWeakReference, Object sender, TEventArgs args)
at Livet.EventListeners.WeakEvents.LivetWeakEventListener`2.<>c__DisplayClass9_0.<GetStaticHandler>b__0(Object sender, TEventArgs e)
at Livet.Messaging.InteractionMessenger.Raise(InteractionMessage message)
at SampleAppNetCore.MainWindowViewModel.OpenFolderBrowser() in ...
MainWindow.xaml
<Window x:Class="SampleAppNetCore.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:l="http://schemas.livet-mvvm.net/2011/wpf"
xmlns:i="http://schemas.microsoft.com/xaml/behaviors"
xmlns:local="clr-namespace:SampleAppNetCore"
mc:Ignorable="d"
Title="MainWindow" Height="450" Width="800">
<Window.DataContext>
<local:MainWindowViewModel/>
</Window.DataContext>
<i:Interaction.Triggers>
<l:InteractionMessageTrigger MessageKey="show_selectfolderdialog" Messenger="{Binding Messenger}">
<l:FolderBrowserDialogInteractionMessageAction/>
</l:InteractionMessageTrigger>
</i:Interaction.Triggers>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition />
</Grid.RowDefinitions>
<Menu>
<MenuItem Header="File">
<MenuItem Header="Open FolderBrowser" Command="{Binding OpenFolderBrowserCommand}"/>
</MenuItem>
</Menu>
</Grid>
</Window>
MainWindowViewModel.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Text;
using Livet;
using Livet.Commands;
using Livet.Messaging;
using Livet.Messaging.IO;
namespace SampleAppNetCore
{
class MainWindowViewModel : ViewModel
{
#region コマンド: OpenFolderBrowserCommand
private ViewModelCommand _OpenFolderBrowserCommand;
public ViewModelCommand OpenFolderBrowserCommand => _OpenFolderBrowserCommand ?? (_OpenFolderBrowserCommand = new ViewModelCommand(OpenFolderBrowser, CanOpenFolderBrowser));
public bool CanOpenFolderBrowser() => true;
public void OpenFolderBrowser()
{
if (!CanOpenFolderBrowser()) return;
var message = new FolderSelectionMessage("show_selectfolderdialog") {
Title = "Save image files",
};
Messenger.Raise(message);
if (string.IsNullOrWhiteSpace(message.Response)) {
return;
}
var folderPath = message.Response;
Debug.WriteLine(folderPath);
}
#endregion
}
}
public class FolderBrowserDialogInteractionMessageAction : InteractionMessageAction<FrameworkElement>
{
protected override void InvokeAction(InteractionMessage m)
{
if (m is FolderSelectionMessage folderSelectionMessage)
{
var hostWindow = Window.GetWindow(AssociatedObject ?? throw new InvalidOperationException());
if (hostWindow == null) return;
using (var dialog = FolderSelectionDialogFactory.CreateDialog(folderSelectionMessage.DialogPreference))
{
if (dialog == null) throw new InvalidOperationException();
dialog.Title = folderSelectionMessage.Title;
dialog.Description = folderSelectionMessage.Description;
dialog.SelectedPath = folderSelectionMessage.SelectedPath;
dialog.Multiselect = folderSelectionMessage.Multiselect;
if (dialog.ShowDialog(hostWindow).GetValueOrDefault())
{
// V3.2.3.2 code -> InvalidOperationException
---> folderSelectionMessage.SelectedPaths = dialog.SelectedPaths;
folderSelectionMessage.Response = folderSelectionMessage.SelectedPaths.FirstOrDefault();
// V2.2.0 code -> No exception
//folderSelectionMessage.Response = dialog.SelectedPath;
} else
{
folderSelectionMessage.Response = null;
}
}
}
}
}
#いつもLivetを愛用しています。runceelさんメンテナンスありがとうございます。
FolderSelectionMessageにおいて、複数のファイルを選択することはできますか?
さらに言えば、フォルダとファイルを混ぜて複数選択することは可能ですか。
よろしくおねがいします。
奥田と申します。
VisualStudio2019にて新規プロジェクトでLivetテンプレートを使用するとClickOnceによる発行ができません。
これは、Livetのテンプレートに問題があるのでしょうか?
それとも、VisualStudio2019側に問題があるのでしょうか?
v3.2.1 の Livet 拡張機能で現象を確認
Hi
I used FolderSelectionMessage
to Folder select dialog.
Ver 3.2.3 cause.
Ver 3.2.2 dose not cause.
MainWindow.xaml
<Window
x:Class="FolderSelectDialogLivetTest.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:behaviors="http://schemas.microsoft.com/xaml/behaviors"
xmlns:l="http://schemas.livet-mvvm.net/2011/wpf">
<Grid>
<Button Content="Folder Dialog">
<behaviors:Interaction.Triggers>
<behaviors:EventTrigger EventName="Click">
<l:FolderBrowserDialogInteractionMessageAction>
<l:DirectInteractionMessage>
<l:FolderSelectionMessage />
</l:DirectInteractionMessage>
</l:FolderBrowserDialogInteractionMessageAction>
</behaviors:EventTrigger>
</behaviors:Interaction.Triggers>
</Button>
</Grid>
</Window>
FolderSelectDialogLivetTest.csproj
<Project Sdk="Microsoft.NET.Sdk.WindowsDesktop">
<PropertyGroup>
<OutputType>WinExe</OutputType>
<TargetFramework>netcoreapp3.1</TargetFramework>
<UseWPF>true</UseWPF>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="LivetCask" Version="3.2.3" />
<PackageReference Include="LivetExtensions" Version="3.2.3" />
</ItemGroup>
</Project>
System.IO.FileNotFoundException
HResult=0x80070002
Message=Could not load file or assembly 'Microsoft.WindowsAPICodePack.Shell, Version=1.1.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'. 指定されたファイルが見つかりません。
Source=Livet.Extensions
スタック トレース:
at Livet.Dialogs.FolderSelectionDialogFactory.get_CanUseCommonItemDialog()
at Livet.Dialogs.FolderSelectionDialogFactory.CreateDialog(FolderSelectionDialogPreference preference)
at Livet.Behaviors.Messaging.IO.FolderBrowserDialogInteractionMessageAction.InvokeAction(InteractionMessage m)
at Livet.Behaviors.Messaging.InteractionMessageAction`1.Invoke(Object parameter)
at Microsoft.Xaml.Behaviors.TriggerBase.InvokeActions(Object parameter)
at Microsoft.Xaml.Behaviors.EventTriggerBase.OnEvent(EventArgs eventArgs)
at Microsoft.Xaml.Behaviors.EventTriggerBase.OnEventImpl(Object sender, EventArgs eventArgs)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
at System.Windows.Controls.Primitives.ButtonBase.OnClick()
at System.Windows.Controls.Button.OnClick()
at System.Windows.Controls.Primitives.ButtonBase.OnMouseLeftButtonUp(MouseButtonEventArgs e)
at System.Windows.UIElement.OnMouseLeftButtonUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
at System.Windows.UIElement.OnMouseUpThunk(Object sender, MouseButtonEventArgs e)
at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
at System.Windows.Input.InputManager.ProcessStagingArea()
at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)
at MS.Win32.UnsafeNativeMethods.DispatchMessage(MSG& msg)
at System.Windows.Threading.Dispatcher.PushFrameImpl(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.PushFrame(DispatcherFrame frame)
at System.Windows.Threading.Dispatcher.Run()
at System.Windows.Application.RunDispatcher(Object ignore)
at System.Windows.Application.RunInternal(Window window)
at System.Windows.Application.Run()
at FolderSelectDialogLivetTest.App.Main()
Livetを使わせて頂いています。
どこに質問を投げればいいのかわからなかったため、こちらに投稿させていただきました。
Messengerを使用し、InformationMessageをViewに渡すことでメッセージボックスを表示しているのですが、
このメッセージボックスにMessageBoxImageを指定する方法はないのでしょうか?
FolderBrowserDialog でキャンセルボタンが押された際、FolderSelectionMessage.Response は null になるようですので、できれば FolderSelectionMessage.Response の型は null 許容型にしていただけるとありがたいです。
DataTriggerですが、本家の方で初期値に対応する修正が行われたようです。
microsoft/XamlBehaviorsWpf#64
LivetDataTriggerの役目は終えたようです。
経緯:
null
許容かどうかを調査してみたところ,null
チェックが抜けている部分を複数発見しましたので, terasato:AddParamChecks としてプルリクを出しました(まだまだ出てくると思います調査で気づいたのですが,DispatcherCollection.Dispatcher
は
null
チェックがありません(null
が代入されうる状態)null
チェックなくメソッド呼び出しがされています(NullReferenceException
がスローされる可能性があります。例:Dispatcher.CheckAccess()
)DispatcherCollection.Dispatcher
はnull
許容として設計されているのであれば,メソッド呼び出しにnull
チェックを追加する必要があります。null
非許容として設計されているのであれば(そう思ってライブラリを使っていました),setterにnull
チェックを追加する必要があります。
類似の問題はまだまだ出てきそうな感じがしています。安定性向上のため,お付き合いよろしくお願いします。
こんにちは、
少し、困っているところがあるので、ご質問いたします。
DataGridにあるDataGridHyperlinkColumnの中にイベントを設定してほしいですが、EventTriggerのコードはどのように書けばいいでしょうか。
Livetを利用しない場合、このように書きます。
<DataGrid ItemsSource="{Binding ProductModel.ProductList}" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridHyperlinkColumn Header="Product" Binding="{Binding Path='ProductName'}">
<DataGridHyperlinkColumn.ElementStyle>
<Style TargetType="TextBlock">
<EventSetter Event="Hyperlink.Click" Handler="HyperlinkProduct_Click"/>
</Style>
</DataGridHyperlinkColumn.ElementStyle>
</DataGridHyperlinkColumn>
</DataGrid.Columns>
</DataGrid>
HyperlinkProduct_Clickはコードビハインドのメソッドです。DataGridにあるProduct行をクリックするとHyperlinkProduct_Clickを呼ぶということです。
でも、LivetでMVVMパターンで作成するので、コードビハインドを書かなくて、ViewModelにあるメソッドを呼ぶのは正しいですが、EventTriggerのコードはどのように書けばいいでしょうか。下記のコードで呼べませんでした。
<DataGrid ItemsSource="{Binding ProductModel.ProductList}" AutoGenerateColumns="False">
<DataGrid.Columns>
<DataGridHyperlinkColumn Header="Product" Binding="{Binding Path='ProductName'}">
<i:Interaction.Triggers>
<i:EventTrigger EventName="Click">
<l:LivetCallMethodAction
MethodName="HyperlinkProductAction"
MethodTarget="{Binding}"/>
</i:EventTrigger>
</i:Interaction.Triggers>
</DataGridHyperlinkColumn>
</DataGrid.Columns>
</DataGrid>
HyperlinkProductActionはViewModelにあるメソッドです。
ご指導のほどよろしくお願いいたします。
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.