Click here to Skip to main content
15,910,603 members
Home / Discussions / WPF
   

WPF

 
QuestionWPF - Getting a Frame control to scroll the content Pin
Evan Stein31-Oct-08 3:45
Evan Stein31-Oct-08 3:45 
AnswerRe: WPF - Getting a Frame control to scroll the content Pin
Wes Aday31-Oct-08 8:30
professionalWes Aday31-Oct-08 8:30 
GeneralRe: WPF - Getting a Frame control to scroll the content Pin
Evan Stein31-Oct-08 12:13
Evan Stein31-Oct-08 12:13 
GeneralRe: WPF - Getting a Frame control to scroll the content Pin
Wes Aday31-Oct-08 12:48
professionalWes Aday31-Oct-08 12:48 
QuestionHow to add text to richtextbox from different thread with wcf? Pin
Daniel Jansson30-Oct-08 22:34
Daniel Jansson30-Oct-08 22:34 
AnswerRe: How to add text to richtextbox from different thread with wcf? Pin
schiebel-t8-Nov-08 3:21
schiebel-t8-Nov-08 3:21 
GeneralRe: How to add text to richtextbox from different thread with wcf? Pin
Daniel Jansson8-Nov-08 3:29
Daniel Jansson8-Nov-08 3:29 
QuestionHosting .NET 2.0 controls in WPF Pin
Johan Lombaard30-Oct-08 22:17
Johan Lombaard30-Oct-08 22:17 
AnswerRe: Hosting .NET 2.0 controls in WPF Pin
Pete O'Hanlon31-Oct-08 2:26
mvePete O'Hanlon31-Oct-08 2:26 
GeneralRe: Hosting .NET 2.0 controls in WPF Pin
Johan Lombaard2-Nov-08 20:47
Johan Lombaard2-Nov-08 20:47 
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 

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.