datatemplate

XAML Image Quality (interpolation) in a Metro-Style App

笑着哭i 提交于 2019-12-01 06:35:10
Given the following Image object (it's in the DataTemplate of a ListView object): <Image Source="{Binding ImgSource}" ImageOpened="img_ImageOpened" /> how am I supposed to get an high-quality bicubic-interpolated image? (on screen, the size of this Image is smaller than the source PNG, but the default resizing appears to be performed with the poor-quality "nearest neighbor" interpolation). Since I would like to rely on data binding alone (whenever the ImgSource of the associated data item changes, the Image content should change), I've tried to set an ImageOpened handler and change the just

How to set the the zindex of datatemplate's in a longlistselector

元气小坏坏 提交于 2019-12-01 04:47:46
I have a longlistselector with certain images that i add in this longlistselector. I also change the margins of this image to make the image go up or down and so on. But i want to put this image infront of another image in this longlistselector. I have tried using Canvas.Zindex. I have tried setting it at the grid level, at image level and at the top level of of the longlistselector.() But it still doesn't work. Does anybody have some idea's? You can find my code bellow: <phone:LongListSelector x:Name="SouthLongListselector" VerticalAlignment="Bottom" ItemsSource="{Binding Cards}" Canvas

Scroll a new item in a ItemsControl into view

↘锁芯ラ 提交于 2019-12-01 04:15:45
I have an ItemsControl that is databound to a ObservableCollection . I have this method in the code behind which adds a new model to the list. I would then like to scroll the new item (at the bottom of the list) into view. I think the size of the ItemsControl is not yet updated when I am querying the size, since the ActualHeight before and after the addition of the model is the same. The effect of this code is to scroll to a point slightly above the new item. How would I know what the new ActualHeight is going to be? Here is my code: ViewModel.CreateNewChapter(); var height = DocumentElements

Implicit DataTemplate doesn't work

隐身守侯 提交于 2019-12-01 03:57:14
Why does the following implicit DataTemplate not work? Only the commented inline DataTemplate will work. Note: If I remove both DataTemplate s, I see a string representation of the ProductListView full type name. <Window.Resources> <DataTemplate DataType="vm:ProductListViewModel"> <v:ProductListView/> </DataTemplate> </Window.Resources> <TabControl ItemsSource="{Binding Tabs}" TabStripPlacement="Left"> <TabControl.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding Key}"/> </DataTemplate> </TabControl.ItemTemplate> <TabControl.ContentTemplate> <DataTemplate> <ContentPresenter Content="

XAML Image Quality (interpolation) in a Metro-Style App

落花浮王杯 提交于 2019-12-01 03:36:44
问题 Given the following Image object (it's in the DataTemplate of a ListView object): <Image Source="{Binding ImgSource}" ImageOpened="img_ImageOpened" /> how am I supposed to get an high-quality bicubic-interpolated image? (on screen, the size of this Image is smaller than the source PNG, but the default resizing appears to be performed with the poor-quality "nearest neighbor" interpolation). Since I would like to rely on data binding alone (whenever the ImgSource of the associated data item

Focus on a TextBox in a DataTemplate

自作多情 提交于 2019-12-01 03:28:51
I have DataTemplate containing a TextBox . I'm setting this template to a listbox item on a selection. I'm unable to set focus to textbox in the template. I tried to call MyTemplate.FindName, but it ends up with an Invalid Operation Exception: This operation is valid only on elements that have this template applied. How can I access it? Matt Hamilton Since you know the name of the TextBox you want to focus, this becomes relatively easy. The idea is to get hold of the template as it's applied to the ListBoxItem itself. First thing you want to do is get the selected item: var item = listBox1

WPF ListBox - Getting UIElement instead of of SelectedItem

邮差的信 提交于 2019-12-01 02:44:31
I created a ListBox that has a DataTemplate as Itemtemplate . However, is there an easy way to access the generated UIElement instead of the SelectedItem in codebehind? When I access SelectedItem , I just get the selected object from my ItemsSource collection. Is there a way to access the UIElement (ie. the element generated from the DataTemplate together with the bound object)? Szymon Rozga You are looking for the ItemContainerGenerator property. Each ItemsSource has an ItemContainerGenerator instance. This class has the following method that might interest you: ContainerFromItem(object

Are recursive DataTemplates possible?

我们两清 提交于 2019-12-01 02:32:30
I have a class something like: public class Section { private IEnumerable<Section> sections; private IEnumerable<KeyValuePair<string, string>> attributes public string Name {get;set;} public IEnumerable<Section> Sections { get {return sections;} } public IEnumerable<KeyValuePair<string, string>> Attributes { get {return attributes;} } public Section(...) { //constructor logic } } Which is contained in another class, lets call it OtherClass for sake of argument, that wraps around it and is used in WPF in an ObjectDataProvider. As you can see, an instance of Section can contain many other

Binding to property in owning window's viewmodel within a DataTemplate in Window.Resources

若如初见. 提交于 2019-11-30 23:25:55
I have a DataTemplate within my Window's Resources section that creates a TextBlock with a ContextMenu. I want to be able to set whether a MenuItem within the ContextMenu is visible from within my Window's view model. I have tried accessing the DataContext of the Window by setting ElementName , and also tried setting RelativeSource , but both approaches resulted in binding errors. I'm not sure what else I can try. I have created a small example that shows what I'm trying to do: XAML: <Window x:Class="DataTemplateTest.MainWindow" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"

TextBlock text wrapping in GridViewColumn.CellTemplate not working

我的梦境 提交于 2019-11-30 23:13:23
问题 I am having problems getting the TextWrapping to work in this example. Can anyone see what I am duing wrong here? <ListView Name="listViewReportedException" ItemsSource="{Binding ExceptionDetails}"> <ListView.View> <GridView> <GridViewColumn Header="Time" DisplayMemberBinding="{Binding Thrown}" Width="150" /> <GridViewColumn Header="Description" DisplayMemberBinding="{Binding Description}" Width="385"> <GridViewColumn.CellTemplate> <DataTemplate> <TextBlock TextWrapping="Wrap" Text="{Binding}