<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Võ Tấn Đức's blog]]></title><description><![CDATA[Võ Tấn Đức's blog]]></description><link>https://votanduc.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 18 Sep 2026 00:56:51 GMT</lastBuildDate><atom:link href="https://votanduc.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[Cách dùng Interaction .NET core và .NET Famework trong Visual Studio]]></title><description><![CDATA[Interaction giúp cho chúng ta có thể binding bất cứ event nào, nó ứng dụng cho mô hình MVVM trong WPF. Ta không cần xuống code behind để viết code cho 1 event nào cho control, ta chỉ cần tạo ra 1 lớp ViewModel để làm DataContext cho Window mà ta đang...]]></description><link>https://votanduc.hashnode.dev/cach-dung-interaction-net-core-va-net-famework-trong-visual-studio</link><guid isPermaLink="true">https://votanduc.hashnode.dev/cach-dung-interaction-net-core-va-net-famework-trong-visual-studio</guid><category><![CDATA[wpf]]></category><category><![CDATA[MVVM]]></category><category><![CDATA[interaction]]></category><dc:creator><![CDATA[Võ Tấn Đức]]></dc:creator><pubDate>Fri, 17 Mar 2023 11:54:48 GMT</pubDate><enclosure url="https://cdn.hashnode.com/res/hashnode/image/upload/v1681278973667/fb2e8097-9681-4ca7-8d14-94aabd8a2c72.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>Interaction giúp cho chúng ta có thể binding bất cứ event nào, nó ứng dụng cho mô hình MVVM trong WPF. Ta không cần xuống code behind để viết code cho 1 event nào cho control, ta chỉ cần tạo ra 1 lớp ViewModel để làm DataContext cho Window mà ta đang thực hiện và trong ViewModel đó, ta tạo command xử lý event cho control.</p>
<p><strong>Cách dùng Interaction cho .NET Framework:</strong></p>
<ul>
<li><p>Đầu tiên, chúng ta cài thư viện: <strong>Install-Package</strong> <a target="_blank" href="http://System.Windows"><strong>System.Windows</strong></a><strong>.Interactivity.WPF</strong></p>
</li>
<li><p>Tiếp theo, chúng ta đặt đoạn code sau vào control nào chúng ta muốn binding event:</p>
<p>  <code>&lt;i:Interaction.Triggers&gt;</code></p>
<p>  <code>&lt;i:EventTrigger EventName="&lt;Tên event&gt;"&gt; &lt;i:InvokeCommandAction Command="{Binding &lt;Tên command dưới ViewModel&gt;}"/&gt; &lt;/i:EventTrigger&gt;</code></p>
</li>
<li><p><code>&lt;/i:Interaction.Triggers&gt;</code></p>
<p>  <strong>Cách dùng Interaction cho .NET core:</strong></p>
<ul>
<li><p>Đầu tiên, chúng ta cài thư viện bằng cách vào tools -&gt; NuGet Package Manager -&gt; Package Manager Console -&gt; gõ:</p>
</li>
<li><p><code>Install-package Microsoft.xaml.Behaviors.wpf</code></p>
</li>
<li><p>Trong MainWindow.xaml:</p>
</li>
<li><p><code>xmlns:i="</code><a target="_blank" href="http://schemas.microsoft.com/xaml/behaviors"><code>http://schemas.microsoft.com/xaml/behaviors</code></a><code>"</code></p>
</li>
</ul>
</li>
</ul>
]]></content:encoded></item></channel></rss>