我为Button创建了一个Blend行为.如何将其设置为应用程序中的所有按钮.
<Button ...>
<i:Interaction.Behaviors>
<local:MyBehavior />
</i:Interaction.Behaviors>
</Button>
Run Code Online (Sandbox Code Playgroud)
但是,当我尝试:
<Style>
<Setter Property="i:Interaction.Behaviors">
<Setter.Value>
<local:MyBehavior />
</Setter.Value>
</Setter>
</Style>
Run Code Online (Sandbox Code Playgroud)
我收到了错误
"行为"属性没有可访问的setter.
我有listview,当有人双击任何位置时,我想要显示新窗口.但我有mvvm应用程序,我不希望在xaml文件的代码后面有任何函数,如下所示:如何绑定一个Command来双击DataGrid中的一行以及许多其他样本.我想在viewmodel文件中有方法并将其绑定如下:
<ListView ... MouseDoubleClick="{Binding myfunction}">
Run Code Online (Sandbox Code Playgroud)
谢谢
我试图在双击事件后从数据网格中检索行信息.我有事件设置,但现在我只需要设置函数来从行中检索数据.
XAML:
<DataGrid
Width="Auto"
SelectionMode="Extended"
IsReadOnly="True"
Name="ListDataGrid"
AutoGenerateColumns="False"
ItemsSource="{Binding ListFieldObject.MoviesList}"
DataContext="{StaticResource MovieAppViewModel}"
cal:Message.Attach="[Event MouseDoubleClick] = [Action RowSelect()]">
<DataGrid.Columns>
<DataGridTextColumn Width="200" IsReadOnly="True" Header="Title" Binding="{Binding Title}"/>
<DataGridTextColumn Width="100" IsReadOnly="True" Header="Rating" Binding="{Binding Rating}"/>
<DataGridTextColumn Width="100" IsReadOnly="True" Header="Stars" Binding="{Binding Stars}"/>
<DataGridTextColumn Width="93" IsReadOnly="True" Header="Release Year" Binding="{Binding ReleaseYear}"/>
</DataGrid.Columns>
</DataGrid>
Run Code Online (Sandbox Code Playgroud)
C#(MVVM ViewModel):
public void RowSelect()
{
//now how to access the selected row after the double click event?
}
Run Code Online (Sandbox Code Playgroud)
非常感谢!