我正在使用wpf工具包AutoCompleteBox,我已经设置了Item模板.问题:弹出列表中的项目看起来很棒,但它对上面的文本框(选定项目)没有生效.
XAML:
<Controls:AutoCompleteBox x:Name="x" ItemFilter="SearchPerson" Margin="20">
<Controls:AutoCompleteBox.ItemTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal">
<TextBlock Text="{Binding Name}" />
<Rectangle Width="10" Height="10" Fill="LightGreen"/>
<TextBlock Text="{Binding Age}" />
</StackPanel>
</DataTemplate>
</Controls:AutoCompleteBox.ItemTemplate>
</Controls:AutoCompleteBox>
Run Code Online (Sandbox Code Playgroud)
代码背后:
public partial class MainWindow : Window
{
public List<Person> Persons { get; set; }
public MainWindow() {
InitializeComponent();
Persons = new List<Person> {
new Person{Name = "Jhon",Age=35},
new Person{Name = "Kelly",Age=40}};
x.ItemsSource = Persons;
DataContext = this;
}
bool SearchPerson(string search, object value) {
return (value as Person).Name.ToLower().Contains(search);
}
}
public class Person …
Run Code Online (Sandbox Code Playgroud) System.Windows.Data Error: 5 :
Value produced by BindingExpression is not valid for target property.;
Value='<null>' BindingExpression:Path=Attributes[AssetSL];
DataItem='DataBinding' (HashCode=4074007);
target element is 'RegionSSIn' (Name='rssi');
target property is 'AService' (type 'SLG')
Run Code Online (Sandbox Code Playgroud)
那异常是什么意思?
可以给我一个例子为什么我需要一个ViewModel taht包含两个子View模型?我该如何实现呢?
MVVM不允许代码隐藏,因此事件处理.那么什么是MVVM通知单元格被更改的方式?
我已经尝试过MSDN但是没有从Freezable派生的例子.
更新:
在MSDN中是的,有一个动画示例,但它太复杂了.需要更简单的东西来理解freezable.
在WPF中,实现下图所示控件的最佳方法是什么?您有很多图像,但不能一次看到所有图像,但是您可以左右左右滚动或滚动,我不确定如何调用它。侧面的两个按钮向右和向左滚动并显示新图像。
我在 WPF 中使用 3d 并想将它保存到一个 2d 图像文件,一种屏幕截图。最好的方法是什么?
我在c#中有不同类型的对象,我想保存到文件(XML是首选)但我不能使用序列化,因为该类不是由我编写的,而是来自DLL.
什么是最好的解决方案?
我有一个家庭作业:
需要实现一个获取INT数组和数字的函数(RotateRight):
int[] res = RotateRight(new int[] { 1, 2, 3, 4, 5, 6 }, 2);
//so then res will be {5,6,1,2,3,4}
Run Code Online (Sandbox Code Playgroud)
并根据给出的数字将所有项目向右旋转后返回数组,在我们的例子中为2.
而且我必须在内存空间方面有效地做到这一点.
我最好的想法是:
如果给出的数字是x,则使用x大小的新int [] tmpArray将所有最后x个项目复制到它.然后使用for循环将int的所有其余部分向右移动.最后将tmpArray中的项目复制到原始数组的开头.
提前感谢任何建议或帮助