Hello, I have a WPF form, with a ListView element, and I need to access to it from an external class but in the same file: Page1.xaml.cs, this is my form:
Page1.xaml:
<Page x:Class="WpfBrowserApplication1.Page1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Page1">
<Grid Height="440" Width="658">
<ListView Margin="10,18,8,148.616" Name="listView1" />
<Button Height="32" HorizontalAlignment="Left" Margin="14,0,0,110" Name="button1" VerticalAlignment="Bottom" Width="111" Click="button1_Click">Primera Carga</Button>
<Label Height="29" Margin="100,0,10,48" Name="label1" VerticalAlignment="Bottom">Label</Label>
</Grid>
</Page>
It's a very simple form, and I neew to access to the listView element from another class that is not Page1:
namespace WpfBrowserApplication1
{
public partial class Page1 : Page
{
public Page1()
{
InitializeComponent();
}
}
public class CallbackHandler : IServiceDuplexCallback
{
public void Send(Dictionary d)
{
///////HERE : listView1.ItemsSource = d;
//I can do it without problem in Page1 class, but not here
}
}
}
I need to access listView item from the Send method of class CallbackHandler, but I can't see the element and I can't use it, I've read that I have to expose the item as public, because XAML creates the elements as private by default, but I don't know how to do it, neither where, if it is in Page1.xaml or if I have to modify a property of the element in the designer.
I need to access the listView item in CallBackHandler class because it's the client of a Duplex WCF service, so the service to send the results to the client, executes the Send method, and I need to update the listView itemsSource from there.
I think this should be simple, but I'm new to WPF and I need a little help.
Hope you can help me, Thanks a lot!!