<localControls:MediaList x:Name="NewMediaList">
<localControls:MediaList.ToolsBar>
<Button Content="{StaticResource ResourceKey=MoveToPlaylist}"
IsEnabled="{Binding ElementName=NewMediaList, Path=SelectedMedia, Converter={localConverters:ObjectToBool}}"/>
</localControls:MediaList.ToolsBar>
</localControls:MediaList>
<UserControl x:Class="MediaPlaylist.Controls.MediaList"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
xmlns:localConverters="clr-namespace:Suisse.MediaPlaylist.Converters"
mc:Ignorable="d"
d:DesignHeight="300" d:DesignWidth="300"
x:Name="MediaListControl">
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="Auto"/>
</Grid.RowDefinitions>
<DataGrid Grid.Row="0"
AutoGenerateColumns="False"
ItemsSource="{Binding ElementName=MediaListControl, Path=Playlist.Medias}"
SelectedItem="{Binding ElementName=MediaListControl, Path=SelectedMedia, Mode=TwoWay}">
<DataGrid.Columns>
<DataGridTextColumn Header="Title"
Binding="{Binding Title}"
IsReadOnly="True"/>
<DataGridTextColumn Header="File"
Binding="{Binding FilePath}"
IsReadOnly="True"/>
</DataGrid.Columns>
</DataGrid>
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Right"
Grid.Row="1">
<ItemsControl ItemsSource="{Binding ElementName=MediaListControl, Path=ToolsBar}">
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
<Separator Visibility="{Binding ElementName=MediaListControl, Path=ToolsBar.Count, Converter={localConverters:ObjectToVisibility}}" />
<Button
HorizontalAlignment="Right"
Content="Delete"
Click="OnDelete_Click"
IsEnabled="{Binding ElementName=MediaListControl, Path=SelectedMedia, Converter={localConverters:ObjectToBool}}"/>
</StackPanel>
</Grid>
谢谢
public partial class MediaList : UserControl
{
public MediaList()
{
InitializeComponent();
}
public static DependencyProperty ToolsBarProperty = DependencyProperty.
Register("ToolsBar", typeof(ItemsControl), typeof(MediaList));
public ItemsControl ToolsBar
{
get { return (ItemsControl)GetValue(ToolsBarProperty); }
set { SetValue(ToolsBarProperty, value); }
}
}
<StackPanel Orientation="Horizontal"
HorizontalAlignment="Right"
Grid.Row="1">
<ContentControl Content="{Binding ElementName=MediaListControl, Path=ToolsBar}">
</ContentControl>
<localControls:MediaList>
<localControls:MediaList.ToolsBar>
<ItemsControl >
<ItemsControl.Items>
<Button Content="{StaticResource ResourceKey=MoveToPlaylist}"
IsEnabled="{Binding ElementName=NewMediaList, Path=SelectedMedia, Converter={localConverters:ObjectToBool}}"/>
<Label>Hello </Label>
<Label> How are you?</Label>
</ItemsControl.Items>
<ItemsControl.ItemsPanel>
<ItemsPanelTemplate>
<StackPanel Orientation="Horizontal" />
</ItemsPanelTemplate>
</ItemsControl.ItemsPanel>
</ItemsControl>
</localControls:MediaList.ToolsBar>
</localControls:MediaList>
上面的示例工作正常,因为版本1.0-rc4修复了需要不必要变量的问题。 我完全按照它在留档中的描述,它不起作用: main.xml: buttons.xml: MyActivity.java: 如何获取按钮?
我想包括一个布局与数据绑定。 我想使用将id从java传递到布局,但我似乎找不到正确的语法。 这是我的片段类,带有和: 我想充气。分割项目,并使其包含
我在我的页面上有一个引导下拉列表,它是动态填充的,没有删除数据。标准引导下拉列表如下所示: 请注意,下拉列表的标题将是下拉列表,而带类克拉的跨度将添加向下的克拉图标,使其看起来像下拉框。 问题是当我添加一个数据绑定来更改选择菜单标题的文本时,就像这样(为了简单起见,省略了一些类): MenuTitle只是一个简单的ko。可以通过文本观察到。 它以克拉覆盖跨度。数据如何绑定按钮的文本,并且仍然在其中
当使用(来自maven central或生成mojo时的输出)时,SLF4j会给出错误 SLF4J:类路径包含多个SLF4J绑定 SLF4J:在[jar:file:~/.ivy2/cache/org.SLF4J/slf4j-log4j12/jars/slf4j-log4j12/jars/slf4j-log4j12-1.7.5.jar!/org/SLF4J/impl/staticloggerbind
如何将MVVM值绑定到dropdownlist?下面的输入元素运行良好