findname

Find TextBox in a DataTemplate

人盡茶涼 提交于 2020-01-06 12:35:12
问题 Have some elements in a DataTemplate that I need to access in a code behind event handler. Below works if the button and the textbox have the same Parent. How would I handle a more complex layout? If there a general way for accessing an element in a DataTemplate? XAML <DataTemplate x:Key="fieldDateTemplate"> <StackPanel> <DatePicker SelectedDate="{Binding Path=FieldValue}" /> <TextBox x:Name="tbFindMe" Text="findME"/> <Button Content="FindTB" Click="FindTB_click" Width="60"

Why doesnt Window.FindName() discover the x:Name of a button in a child UserControl? AKA how do NameScopes work?

*爱你&永不变心* 提交于 2019-12-19 08:06:44
问题 So in the example code below, I create a UserControl UserControldChild which is a child of the main Window, Window1.xaml. Why does the FindName() method fail to find the "myButton" in the code below? This must have to do with the WPF XAML NameScopes, but I have yet to find a good explanation as to how NameScope works. Can someone enlighten me? //(xml) Window1.xaml <Window x:Class="VisualTreeTestApplication.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x=

Access Elements inside a DataTemplate… How to for more than 1 DataTemplate?

元气小坏坏 提交于 2019-12-18 07:08:11
问题 I've got 2 DataTemplates defined for a Listbox Control. 1 Template is for the UnSelected State and the other one is for the Selected State(showing more detail than the UnSelected State). I followed the example here: http://blogs.msdn.com/b/wpfsdk/archive/2007/04/16/how-do-i-programmatically-interact-with-template-generated-elements-part-ii.aspx about how to access the Elements inside the DataTemplates from Code behind. I get it right, but it only finds and returns an element of the UnSelected

Get Image in currently selected PanoramaItem

流过昼夜 提交于 2019-12-12 01:07:36
问题 I have a Panorama which gets a dynamic amount of items based on data binding. In the created PanoramaItem, I have an Image which I want to modify over time (fade in/out different images over time). I saw similar questions like this: How to retrieve the name of a Panorama-Item at runtime? but that does not work for me as I never get a PanoramaItem when I use Panorama.Items[index] . I only get an instance of the data binding I use. I come from the Android world where I could simple use

Why doesnt Window.FindName() discover the x:Name of a button in a child UserControl? AKA how do NameScopes work?

微笑、不失礼 提交于 2019-12-01 06:38:35
So in the example code below, I create a UserControl UserControldChild which is a child of the main Window, Window1.xaml. Why does the FindName() method fail to find the "myButton" in the code below? This must have to do with the WPF XAML NameScopes , but I have yet to find a good explanation as to how NameScope works. Can someone enlighten me? //(xml) Window1.xaml <Window x:Class="VisualTreeTestApplication.Window1" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:VisualTreeTestApp="clr-namespace

Access Elements inside a DataTemplate… How to for more than 1 DataTemplate?

匆匆过客 提交于 2019-11-29 12:39:34
I've got 2 DataTemplates defined for a Listbox Control. 1 Template is for the UnSelected State and the other one is for the Selected State(showing more detail than the UnSelected State). I followed the example here: http://blogs.msdn.com/b/wpfsdk/archive/2007/04/16/how-do-i-programmatically-interact-with-template-generated-elements-part-ii.aspx about how to access the Elements inside the DataTemplates from Code behind. I get it right, but it only finds and returns an element of the UnSelected DataTemplate. But when i search for an element in the Selected DataTemplate i get a

WPF - FindName Returns null when it should not

夙愿已清 提交于 2019-11-28 08:03:57
FindName is broken for me :( If you are an expert in such things I would love some help. The object I am looking for is there. I have proof. Here is the scenario: ToggleButton button = (ToggleButton)sender; Popup popup = (Popup)button.FindName("popSelectIteration"); popup is null but not always. Just sometimes. But even when it is set to null the child I am looking for is there. I put a break point in when it was null and grabbed these two screenshots. The is where FindName is returning null for "popSelectIteration": alt text http://img175.imageshack.us/img175/2055/popupisnull.png But if you

WPF - FindName Returns null when it should not

只谈情不闲聊 提交于 2019-11-27 02:03:09
问题 FindName is broken for me :( If you are an expert in such things I would love some help. The object I am looking for is there. I have proof. Here is the scenario: ToggleButton button = (ToggleButton)sender; Popup popup = (Popup)button.FindName("popSelectIteration"); popup is null but not always. Just sometimes. But even when it is set to null the child I am looking for is there. I put a break point in when it was null and grabbed these two screenshots. The is where FindName is returning null