我正在尝试使用Label控件在XAML中显示一个字符串.以下是我的XAML代码:
<Label Height="28" HorizontalAlignment="Left" Margin="233,68,0,0" Name="label13" VerticalAlignment="Top">
<Label.Content>
<MultiBinding StringFormat="{}{0} x {1}">
<Binding Path="Width" />
<Binding Path="Height" />
</MultiBinding>
</Label.Content>
Run Code Online (Sandbox Code Playgroud)
宽度和高度是我的类Movie的两个属性.我希望标签显示:"宽度x高度"ex.800 x 640但标签控件仍为空.任何帮助表示赞赏.我想在不使用转换器的情况下做这件事.
我使用TextBlock而不是Label修改了我的xaml.但它仍然不会填充显示输出.
<TextBlock Height="28" HorizontalAlignment="Left" Margin="233,68,0,0" Name="label13" VerticalAlignment="Top">
<TextBlock.Text>
<MultiBinding StringFormat="{}{0} x {1}">
<Binding Path="Width" />
<Binding Path="Height" />
</MultiBinding>
</TextBlock.Text>
</TextBlock>
Run Code Online (Sandbox Code Playgroud) 我有以下XAML.如何突出显示ItemsControl中的所选项?我可以覆盖ListView的选定项目模板,但如何为ItemsControl实现相同的功能?有没有可以显示图像集的替代控件?
<Window x:Class="ImageScrollDemo.View.MoviePosterView"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ImageScrollDemo"
xmlns:i="clr-namespace:System.Windows.Interactivity;assembly=System.Windows.Interactivity"
Title="MoviePosterView" Height="367" Width="725" Foreground="White">
<Window.Background>
<LinearGradientBrush StartPoint="0,0" EndPoint="0,1">
<GradientStop Color="#FF505050" Offset="0"/>
<GradientStop Color="#FF202020" Offset="1"/>
</LinearGradientBrush>
</Window.Background>
<Window.DataContext>
<local:MainWindowViewModel />
</Window.DataContext>
<Window.Resources>
<local:MainWindowViewModel x:Key="ViewModel" />
<Style TargetType="Image" x:Key="ImageHover">
<Style.Triggers>
<Trigger Property="IsMouseOver" Value="True">
<Setter Property="Opacity" Value="1" />
<Setter Property="BitmapEffect">
<Setter.Value>
<OuterGlowBitmapEffect GlowColor="Gold" GlowSize="8"/>
</Setter.Value>
</Setter>
</Trigger>
<Trigger Property="IsMouseOver" Value="False">
<Setter Property="Opacity" Value="0.7" />
</Trigger>
</Style.Triggers>
</Style>
</Window.Resources>
<i:Interaction.Triggers>
<i:EventTrigger EventName="Loaded">
<i:InvokeCommandAction Command="{Binding PopulateMovieGrid}" />
</i:EventTrigger>
</i:Interaction.Triggers>
<Grid>
<Grid.RowDefinitions>
<RowDefinition Height="*" />
<RowDefinition Height="60" />
</Grid.RowDefinitions> …Run Code Online (Sandbox Code Playgroud) 我有以下类结构:
public class PriceLog
{
public DateTime LogDateTime {get; set;}
public int Price {get; set;}
}
Run Code Online (Sandbox Code Playgroud)
对于List <PriceLog>,我希望Linq查询生成一个输出,该输出等效于如下所示的数据:
LogDateTime | AVG(价格)
2012年1月| 2000年
2月2012 | 3000
简单地说:我想计算一年中每个月的平均价格.
注意:LogDateTime属性应格式化为LogDateTime.ToString("MMM yyyy")
我尝试了以下内容,但不确定它是否会产生所需的结果:
var result = from priceLog in PriceLogList
group priceLog by priceLog.LogDateTime.ToString("MMM yyyy") into dateGroup
select new PriceLog { GoldPrice = (int)dateGroup.Average(p => p.GoldPrice), SilverPrice = (int)dateGroup.Average(p => p.SilverPrice)};
Run Code Online (Sandbox Code Playgroud) 我正在尝试根据以下模型对我的集合进行分组:
public class Person
{
public string FirstName { get; set; }
public string LastName { get; set; }
public Role PersonRole { get; set; }
}
public class Role
{
public int Id { get; set; }
public string RoleName { get; set; }
}
Run Code Online (Sandbox Code Playgroud)
我的PersonCollection,
public ObservableCollection<Person> PersonList;
Run Code Online (Sandbox Code Playgroud)
该集合中填充了三个Person对象,两个具有相同的角色.
我想按照他们的角色名称对所有人进行分组.我有以下XAML:
<Grid.Resources>
<CollectionViewSource x:Key="cvs" Source="{Binding PersonList}">
<CollectionViewSource.GroupDescriptions>
<PropertyGroupDescription PropertyName="PersonRole.RoleName"/>
</CollectionViewSource.GroupDescriptions>
</CollectionViewSource>
</Grid.Resources>
<ListBox ItemsSource="{Binding Source={StaticResource cvs}}">
<ListBox.ItemTemplate>
<DataTemplate>
<TextBlock Text="{Binding FirstName}"/>
</DataTemplate>
</ListBox.ItemTemplate>
<ListBox.GroupStyle>
<GroupStyle>
<GroupStyle.HeaderTemplate>
<DataTemplate>
<TextBlock Text="{Binding …Run Code Online (Sandbox Code Playgroud) 我有一个列表列表对象:
List<List<Movie>> MovieList
Run Code Online (Sandbox Code Playgroud)
该MovieList对象是电影列表的集合,每个电影列表基于特定的电影类型.恩.MovieList[0]将是喜剧类型的电影列表,依此类推现在我想将这个列表列表MovieList对象绑定到XAML中的ListView.ListView ItemSource将绑定到此MovieList对象,此ListView的每个ListViewItem将是一个ListView本身,绑定到特定类型的电影列表.恩.喜剧类型电影列表.此外,此内部List的每个ListViewItem都将绑定到该特定影片的Title属性.请帮我设计XAML代码.
我正在尝试为项目控件中的每个项目设置边框.以下是我的XAML代码.但这不起作用.
<ItemsControl.ItemContainerStyle>
<Style>
<Setter Property="Control.BorderThickness" Value="5" />
<Setter Property="Control.BorderBrush" Value="Black" />
</Style>
</ItemsControl.ItemContainerStyle>
Run Code Online (Sandbox Code Playgroud) 我在MVVM中为WPF DataGrid实现了CollectionViewSource的小型演示.我非常感谢任何帮助来验证实现并评论这是否是使用CollectionViewSource的正确方法.
public class ViewModel : NotifyProperyChangedBase
{
private ObservableCollection<Movie> _movieList;
public ObservableCollection<Movie> MovieList
{
get { return _movieList; }
set
{
if (this.CheckPropertyChanged<ObservableCollection<Movie>>("MovieList", ref _movieList, ref value))
this.DisplayNameChanged();
}
}
private CollectionView _movieView;
public CollectionView MovieView
{
get { return _movieView; }
set
{
if (this.CheckPropertyChanged<CollectionView>("MovieView", ref _movieView, ref value))
this.DisplayNameChanged();
}
}
public ViewModel()
{
MovieView = GetMovieCollectionView(MovieList);
}
private void DisplayNameChanged()
{
this.FirePropertyChanged("DisplayName");
}
public void UpdateDataGrid(string uri)
{
MovieView = GetMovieCollectionView(new ObservableCollection<Movie>(MovieList.Where(mov => uri.Contains(mov.ID.ToString())).ToList<Movie>()));
}
public …Run Code Online (Sandbox Code Playgroud) 我的角度页面有以下Kendo UI gridOptions:
ctrl.gridOptions = {
rowTemplate: '<tr data-uid="#: uid #" class="#:ApprovalStatus=\'Approved\'? \"approved\" : \"unapporved\"#"></tr>',
//rowTemplate: '<tr data-uid="#: uid #" class="#:ApprovalStatus=\'Approved\' ? \'approved\' : \'unapproved\' #"><td>#:ProcessName #</td><td>#:TradeAmount #</td><td>#:AQRID #</td><td>#:ApprovalStatus #</td></tr>',
dataSource: {
type: 'json',
transport: {
read: function (options) {
DataSvc.getTradesData().then(function (response) {
options.success(response.data);
}, function (response) {
alert('something went wrong')
console.log(status);
});
}
},
schema: {
model: {
fields: {
IsChecked: { type: "boolean" },
ProcessName: { type: "string" },
TradeAmount: { type: "number" },
ApprovalStatus: { type: "string" …Run Code Online (Sandbox Code Playgroud) 我有以下用于WPF ListBox控件的xaml.我已经定制了它以满足我的UI要求.但是,滚动条滑块不会到达滚动条的顶部和底部.如果我点击垂直滚动条轨道上的其他位置,拇指也不会滚动.请帮我解决问题.任何帮助表示赞赏.
这是我定制的ListBox控件的快照:

<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:Microsoft_Windows_Themes="clr-namespace:Microsoft.Windows.Themes;assembly=PresentationFramework.Aero"
x:Class="MovieMessageBox.ListBoxStyles2"
x:Name="Window"
Title="ListBoxStyles2"
Width="370" Height="200">
<Window.Resources>
<SolidColorBrush x:Key="ListBorder" Color="#828790"/>
<Style x:Key="ListBoxStyle1" TargetType="{x:Type ListBox}">
<Setter Property="Background" Value="{DynamicResource {x:Static SystemColors.WindowBrushKey}}"/>
<Setter Property="BorderBrush" Value="{StaticResource ListBorder}"/>
<Setter Property="BorderThickness" Value="1"/>
<Setter Property="Foreground" Value="{DynamicResource {x:Static SystemColors.ControlTextBrushKey}}"/>
<Setter Property="ScrollViewer.HorizontalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.VerticalScrollBarVisibility" Value="Auto"/>
<Setter Property="ScrollViewer.CanContentScroll" Value="true"/>
<Setter Property="ScrollViewer.PanningMode" Value="Both"/>
<Setter Property="Stylus.IsFlicksEnabled" Value="False"/>
<Setter Property="VerticalContentAlignment" Value="Center"/>
<Setter Property="Template">
<Setter.Value>
<ControlTemplate TargetType="{x:Type ListBox}">
<Grid>
<Rectangle Fill="Pink" RadiusX="10" RadiusY="10" Opacity="0.195" />
<Border CornerRadius="10" x:Name="Bd" BorderBrush="{TemplateBinding BorderBrush}" BorderThickness="{TemplateBinding BorderThickness}" Padding="1" SnapsToDevicePixels="true">
<ScrollViewer Focusable="false" Padding="{TemplateBinding …Run Code Online (Sandbox Code Playgroud) 
我想删除在上面的datagridcell中可以看到的Romance周围的虚线边框.每当我使用键盘左右导航键时,就会出现边框.我怎么能摆脱它?