Click here to Skip to main content
15,889,200 members
Home / Discussions / WPF
   

WPF

 
GeneralRe: Hosting .NET 2.0 controls in WPF Pin
Pete O'Hanlon3-Nov-08 8:27
mvePete O'Hanlon3-Nov-08 8:27 
QuestionIssue with setting the margin on several WPF controls Pin
robertw01930-Oct-08 17:03
robertw01930-Oct-08 17:03 
AnswerRe: Issue with setting the margin on several WPF controls Pin
User 27100930-Oct-08 19:25
User 27100930-Oct-08 19:25 
GeneralRe: Issue with setting the margin on several WPF controls Pin
robertw01930-Oct-08 19:48
robertw01930-Oct-08 19:48 
GeneralRe: Issue with setting the margin on several WPF controls Pin
User 27100931-Oct-08 3:34
User 27100931-Oct-08 3:34 
GeneralRe: Issue with setting the margin on several WPF controls Pin
robertw01931-Oct-08 13:50
robertw01931-Oct-08 13:50 
GeneralRe: Issue with setting the margin on several WPF controls Pin
User 27100931-Oct-08 13:53
User 27100931-Oct-08 13:53 
QuestionWPF DataBinding & Filtering [modified] Pin
ProjectsRameshBabu30-Oct-08 13:50
ProjectsRameshBabu30-Oct-08 13:50 
XML Data :
<?xml version="1.0" encoding="utf-8" ?>
- <ControlData>
- <Companies>
- <Company ID="100" LocationID="2000">
- <CustomerWindow>
<Email Visibility="Hidden" />
</CustomerWindow>
</Company>
- <Company ID="200" LocationID="2000">
- <CustomerWindow>
<Email Visibility="Hidden" />
</CustomerWindow>
</Company>
- <Company ID="300" LocationID="1000">
- <CustomerWindow>
<Email Visibility="Visible" />
</CustomerWindow>
</Company>
- <Company ID="200" LocationID="1000">
- <CustomerWindow>
<Email Visibility="Visible" />
</CustomerWindow>
</Company>
</Companies>
</ControlData>





public partial class CustomerDetails : Window
{
CollectionViewSource cvs = new CollectionViewSource();
XmlDataProvider dp = new XmlDataProvider();

public CustomerDetails()
{
InitializeComponent();
}

private void Binding()
{
CollectionViewSource vs = this.FindResource("MyCollectionView") as CollectionViewSource;
vs.View.CurrentChanged+=new EventHandler(view_CurrentChanged);
ControlDataViewModel cdvm = new ControlDataViewModel();
XmlDocument dc = new XmlDocument();
dc.LoadXml(cdvm.XmlData);
dp.Document = dc;
dp.XPath = "ControlData/Companies";
cvs.Source = dp;
cvs.Filter += new FilterEventHandler(cvs_Filter);

//Binding Expression
Binding bind = new Binding();
bind.Source = cvs;
bind.XPath = "Company/CustomerWindow/Email/@Visibility";

//Find the Email Control and binds.
ContentPresenter cp = VisualTreeHelper.GetChild(Details, 0) as ContentPresenter;
DataTemplate dat = Details.ContentTemplate;
StackPanel sp = dat.FindName("Test", cp) as StackPanel;
TextBlock tb = sp.FindName("EMail") as TextBlock;
tb.DataContext=cvs.View;
tb.SetBinding(TextBlock.VisibilityProperty, bind);

}

void cvs_Filter(object sender, FilterEventArgs e)
{
CollectionViewSource vs = this.FindResource("MyCollectionView") as CollectionViewSource;
Customer cust = vs.View.CurrentItem as Customer;
XmlElement xdoc = e.Item as XmlElement;
XmlNode node = xdoc.SelectSingleNode("Company[@ID='" + cust.CompanyID + "' and @LocationID='" + cust.LocationID + "']");
if (node != null)
{
e.Accepted = true;
}
else
{
e.Accepted = false;
}
}
void view_CurrentChanged(object sender, EventArgs e)
{
cvs.View.Refresh();

}
private void CustomerWindow_Loaded(object sender, RoutedEventArgs e)
{
Binding();
}
}
XAML :
<Window
x:Class="XamDataGridCurrentItemSync.CustomerDetails"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:igDP="http://infragistics.com/DataPresenter"
xmlns:local="clr-namespace:XamDataGridCurrentItemSync"
Title="Control Data Collection"
Width="400" Height="550"
WindowStartupLocation="CenterScreen" x:Name="CustomerWindow" Loaded="CustomerWindow_Loaded">
<Window.Resources>
<ObjectDataProvider x:Key="MyCustomers" ObjectType="{x:Type local:CustomerViewModel}" />
<CollectionViewSource x:Name="CVS" x:Key="MyCollectionView" Source="{Binding Source={StaticResource MyCustomers},Path=CustomerDataCollection}" />
</Window.Resources>
<Grid>
<StackPanel>
<Border BorderBrush="Black" BorderThickness="2">
<ListView Name="ListViewCustomerDetails" Margin="4,20,40,100" ItemsSource="{Binding Source={StaticResource MyCollectionView}}" IsSynchronizedWithCurrentItem="true">
<ListView.View>
<GridView>
<GridViewColumn Header="First Name" DisplayMemberBinding="{Binding Path=FirstName}"/>
<GridViewColumn Header="Last Name" DisplayMemberBinding="{Binding Path=LastName}"/>
<GridViewColumn Header="EMail" DisplayMemberBinding="{Binding Path=EMail}"/>
</GridView>
</ListView.View>
</ListView>
</Border>
<ContentControl Content="{Binding Source={StaticResource MyCollectionView}}" x:Name="Details">
<ContentControl.ContentTemplate>
<DataTemplate x:Name="Template1">
<StackPanel Margin="20" x:Name="Test">
<TextBlock x:Name="FirstName" Text="{Binding Path=FirstName}" Height="30" />
<TextBlock x:Name="LastName" Text="{Binding Path=LastName}" Height="30" />
<TextBlock x:Name="EMail" Text="{Binding Path=EMail}" Height="50" />
</StackPanel>
</DataTemplate>
</ContentControl.ContentTemplate>
</ContentControl>
</StackPanel>
</Grid>
</Window>

I am binding the Customers to the ListView and contentControl.It works fine.Also i am binding SecurityData which says whether the Email is visible for an customer based on the companyID and LocationId.I have the securitydata in the Xml format.It is binding well for the first record when i navigate between records it is not reapplying the binding based on the filtered data.Please go through the code and give your suggestion why it is not working.

modified on Thursday, October 30, 2008 7:57 PM

QuestionSilverlight and data access Pin
wolfbinary30-Oct-08 10:57
wolfbinary30-Oct-08 10:57 
AnswerRe: Silverlight and data access Pin
Pete O'Hanlon2-Nov-08 11:03
mvePete O'Hanlon2-Nov-08 11:03 
GeneralRe: Silverlight and data access Pin
wolfbinary3-Nov-08 3:08
wolfbinary3-Nov-08 3:08 
GeneralRe: Silverlight and data access Pin
Pete O'Hanlon3-Nov-08 3:27
mvePete O'Hanlon3-Nov-08 3:27 
GeneralRe: Silverlight and data access Pin
wolfbinary3-Nov-08 3:30
wolfbinary3-Nov-08 3:30 
Questionopen aspx page inside Silverlight? Pin
BRY2830-Oct-08 3:31
BRY2830-Oct-08 3:31 
AnswerRe: open aspx page inside Silverlight? Pin
salon7-Nov-08 3:09
salon7-Nov-08 3:09 
QuestionWCF - How to generate a proxy class from a WSDL... Pin
Edmundisme29-Oct-08 15:25
Edmundisme29-Oct-08 15:25 
AnswerRe: WCF - How to generate a proxy class from a WSDL... Pin
Jammer29-Oct-08 23:26
Jammer29-Oct-08 23:26 
GeneralRe: WCF - How to generate a proxy class from a WSDL... Pin
Edmundisme30-Oct-08 8:15
Edmundisme30-Oct-08 8:15 
GeneralRe: WCF - How to generate a proxy class from a WSDL... Pin
Edmundisme30-Oct-08 9:58
Edmundisme30-Oct-08 9:58 
GeneralRe: WCF - How to generate a proxy class from a WSDL... Pin
Jammer30-Oct-08 10:58
Jammer30-Oct-08 10:58 
QuestionWPF Reporting application Pin
kasi1429-Oct-08 11:44
kasi1429-Oct-08 11:44 
AnswerRe: WPF Reporting application Pin
User 27100929-Oct-08 17:33
User 27100929-Oct-08 17:33 
QuestionAdd DHTML to silverlight app? Pin
ginzb7e829-Oct-08 1:47
ginzb7e829-Oct-08 1:47 
AnswerRe: Add DHTML to silverlight app? Pin
Ben4510-Nov-08 2:19
Ben4510-Nov-08 2:19 
NewsXAML Power Toys 3.5 Released Updated For New WPF & Silverlight Toolkits Pin
User 27100928-Oct-08 23:00
User 27100928-Oct-08 23:00 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.