|
What does not work?
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Hi Karl,
Page loading with empty listview items from the ObservableCollections.I hv posted my code behind for your reference.
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using System.Collections.ObjectModel;
using System.ComponentModel;
namespace WPFtest
{
public partial class ComboTest : Page
{
private ObservableCollection<GameData> _GameCollection = new ObservableCollection<GameData>();
private ObservableCollection<Department> _AvailablePublishers = new ObservableCollection<Department>();
private ObservableCollection<Role> _AvailableRoles = new ObservableCollection<Role>();
private GridViewColumnHeader _CurSortCol = null;
private SortAdorner _CurAdorner = null;
public ComboTest()
{
_GameCollection.Add(new GameData {
GameName = "World Of Warcraft",
Creator = "Blizzard",
Publisher = "Blizzard" });
_GameCollection.Add(new GameData {
GameName = "Halo",
Creator = "Bungie",
Publisher = "Microsoft" });
_GameCollection.Add(new GameData {
GameName = "Gears Of War",
Creator = "Epic",
Publisher = "Microsoft" });
_AvailablePublishers.Add(new Department { DeptID = "1", DeptName = "Purchase" });
_AvailablePublishers.Add(new Department { DeptID = "2", DeptName = "production" });
_AvailablePublishers.Add(new Department { DeptID = "3", DeptName = "Inventory" });
InitializeComponent();
}
public ObservableCollection<GameData> GameCollection
{ get { return _GameCollection; } }
public ObservableCollection<Department> AvailablePublishers
{ get { return _AvailablePublishers; } }
public ObservableCollection<Role> AvailableRoles
{ get { return _AvailableRoles ; } }
private void AddRowClick(object sender, RoutedEventArgs e)
{
MessageBox.Show("Hi");
_GameCollection.Add(new GameData {
GameName = "A New Game",
Creator = "A New Creator",
Publisher = "<Select A Publisher>" });
}
private void SortClick(object sender, RoutedEventArgs e)
{
GridViewColumnHeader column =
sender as GridViewColumnHeader;
String field = column.Tag as String;
if (_CurSortCol != null)
{
AdornerLayer.GetAdornerLayer(
_CurSortCol).Remove(_CurAdorner);
gameListView.Items.SortDescriptions.Clear();
}
ListSortDirection newDir = ListSortDirection.Ascending;
if (_CurSortCol == column &&
_CurAdorner.Direction == newDir)
newDir = ListSortDirection.Descending;
_CurSortCol = column;
_CurAdorner = new SortAdorner(_CurSortCol, newDir);
AdornerLayer.GetAdornerLayer(
_CurSortCol).Add(_CurAdorner);
gameListView.Items.SortDescriptions.Add(
new SortDescription(field, newDir));
}
private void ComboBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
{
ComboBox cmbTest = sender as ComboBox;
textBox1.Text = cmbTest.SelectedValue.ToString();
_AvailableRoles.Add(new Role { RoleID = "1", RoleName = "Executive" });
_AvailableRoles.Add(new Role { RoleID = "2", RoleName = "Manager" });
}
private void btnTest_Click(object sender, RoutedEventArgs e)
{
_GameCollection.RemoveAt(1);
}
}
public class Role : DependencyObject
{
public static readonly DependencyProperty role =
DependencyProperty.Register("roleId", typeof(string),
typeof(Role), new UIPropertyMetadata(null));
public string RoleID
{
get { return (string)GetValue(role); }
set { SetValue(role, value); }
}
public static readonly DependencyProperty roleNm =
DependencyProperty.Register("rolenm", typeof(string),
typeof(Role), new UIPropertyMetadata(null));
public string RoleName
{
get { return (string)GetValue(roleNm); }
set { SetValue(roleNm, value); }
}
}
public class Department : DependencyObject
{
public static readonly DependencyProperty DepartId =
DependencyProperty.Register("departmentId", typeof(string),
typeof(Department), new UIPropertyMetadata(null));
public string DeptID
{
get { return (string)GetValue(DepartId); }
set { SetValue(DepartId, value); }
}
public static readonly DependencyProperty DeptNam =
DependencyProperty.Register("deptName", typeof(string),
typeof(Department), new UIPropertyMetadata(null));
public string DeptName
{
get { return (string)GetValue(DeptNam); }
set { SetValue(DeptNam, value); }
}
}
public class GameData : DependencyObject
{
public static readonly DependencyProperty GameNameProperty =
DependencyProperty.Register("GameName", typeof(string),
typeof(GameData), new UIPropertyMetadata(null));
public string GameName
{
get { return (string)GetValue(GameNameProperty); }
set { SetValue(GameNameProperty, value); }
}
public static readonly DependencyProperty CreatorProperty =
DependencyProperty.Register("Creator", typeof(string),
typeof(GameData), new UIPropertyMetadata(null));
public string Creator
{
get { return (string)GetValue(CreatorProperty); }
set { SetValue(CreatorProperty, value); }
}
public static readonly DependencyProperty PublisherProperty =
DependencyProperty.Register("Publisher", typeof(string),
typeof(GameData), new UIPropertyMetadata(null));
public string Publisher
{
get { return (string)GetValue(PublisherProperty); }
set { SetValue(PublisherProperty, value); }
}
}
public class SortAdorner : Adorner
{
private readonly static Geometry _AscGeometry =
Geometry.Parse("M 0,5 L 10,5 L 5,0 Z");
private readonly static Geometry _DescGeometry =
Geometry.Parse("M 0,0 L 10,0 L 5,5 Z");
public ListSortDirection Direction { get; private set; }
public SortAdorner(UIElement element,
ListSortDirection dir)
: base(element)
{ Direction = dir; }
protected override void OnRender(
DrawingContext drawingContext)
{
base.OnRender(drawingContext);
if (AdornedElement.RenderSize.Width < 20)
return;
drawingContext.PushTransform(
new TranslateTransform(
AdornedElement.RenderSize.Width - 15,
(AdornedElement.RenderSize.Height - 5) / 2));
drawingContext.DrawGeometry(Brushes.Black, null,
Direction == ListSortDirection.Ascending ?
_AscGeometry : _DescGeometry);
drawingContext.Pop();
}
}
public class BoolToVisibilityConverter : IValueConverter
{
public object Convert(object value, Type targetType,
object parameter, System.Globalization.CultureInfo culture)
{
bool param = bool.Parse(parameter as string);
bool val = (bool)value;
return val == param ?
Visibility.Visible : Visibility.Hidden;
}
public object ConvertBack(object value, Type targetType,
object parameter, System.Globalization.CultureInfo culture)
{
throw new NotImplementedException();
}
}
}
|
|
|
|
|
I don't see where you have assigned the DataContext.
You must set the ComboTest DataContext to the ComboTest class.
In you Loaded event add this line of code:
this.DataContext = this;
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Hi Karl,
Thanks...now listview loaded with data. I have one more issue, combo box not loaded.pls give me some suggestions. Thanks inadvance
|
|
|
|
|
The ItemsSource is incorrect.
ItemsSource="{Binding ElementName=This
Change to ItemsSource={Binding Path=...}
... is the property name that holds the collection.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Hi,
till combo is not loaded,
<ComboBox Name="cmbTest" SelectedItem="{Binding Path=DeptID}" DisplayMemberPath="DeptName" SelectedValuePath="DeptID" ItemsSource="{Binding ElementName=This,Path=AvailablePublishers}" Style="{StaticResource GridEditStyle}" SelectionChanged="ComboBox_SelectionChanged" />
|
|
|
|
|
laprathab wrote: ItemsSource="{Binding ElementName=This,Path=AvailablePublishers}"
This is wrong. Change to:
ItemsSource="{Binding Path=AvailablePublishers}"
modified 27-Feb-21 21:01pm.
|
|
|
|
|
I hv changed but it was not working.
|
|
|
|
|
I looked at your code again, the ComboBox can't see the Page DataContext.
There are many ways around this issue.
Two simple solutions are;
1. Binding the ItemsSource in code.
2. Add a CollectionViewSource to the Page.Resources section, then bind the ComboBox to the CollectionViewSource. Assign the soure of the CollectionViewSource to your AvailablePublishers. If you use this solution you must set the ComboBox property, IsSynchronizedWithCurrentItem to False since you are binding two ComboBoxes to the same source.
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Thanks very much...I tried 2nd solution that works fine...
|
|
|
|
|
How to use xamDataGrid control in VS2005/VS2008.Please give the complete steps.I have downloaded NetAdvantage winclient WPF.
|
|
|
|
|
Infragistics includes great examples in the downloads. Did you look at them?
modified 27-Feb-21 21:01pm.
|
|
|
|
|
Karl Shifflett wrote: Infragistics includes great examples in the downloads. Did you look at them?
Karl - be reasonable. He wants you to do all his work for him. Why think for yourself when you can get others to do it for you?
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hey Guys,
I am having some trouble adding CoverFlow to my WPF project. I am really quiet new to WPF and Coding in general so forgive me if i say something dumb. The project is very simple, it consists of a single ListBox displaying the contents of a SQL Database using LINQ to SQL. The listbox uses a DataTemplate so that various DB fields are viewable per ListBox item. One of the DB fields is a URL to a Picture, what i would like to be able to do i display only the pictures from the DB in a CoverFlow style ListBox.
I would have no clue where to even start so any help would be greatly appreciated.
Thanks Heaps,
Alex
|
|
|
|
|
Hi wisers,
can anyone suggest me where should the entity translator sit in the layered architecture and why. is it in service layer or in business layer.
Thanks in advance,
BK
|
|
|
|
|
Member 3526851 wrote: where should the entity translator sit in the layered architecture
Well, not in this forum for a start. You might find what you're looking for here[^].
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Hi Friends,
How to host Multiple Silver light User Controls
into asp.net Webparts.My aim is to provide Webparts
Concept Using Silver light Application.
Thanks in Advance.
Muneer
|
|
|
|
|
With a very, very small amount of research you will see how this can be done. Doing the research will develop your skills at problem solving rather than just being given the answer.
only two letters away from being an asset
|
|
|
|
|
Hi all
I am doing a small project in WPF. I am using a grid with controls(labels,text box...)
it is posible to apply zoorm to this grid? as far as I read seems I can only zoom images and canvas
thanks
|
|
|
|
|
You can scale anything you want. Just set up a scale transform and animate it to animate your zoom.
Christian Graus
Driven to the arms of OSX by Vista.
"! i don't exactly like or do programming and it only gives me a headache." - spotted in VB forums.
I can do things with my brain that I can't even google. I can flex the front part of my brain instantly anytime I want. It can be exhausting and it even causes me vision problems for some reason. - CaptainSeeSharp
|
|
|
|
|
Sure you can. Here's a sample:
<Page
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<Grid>
<Grid.RenderTransform>
<ScaleTransform
CenterX="0"
CenterY="0"
ScaleX="{Binding Value, Mode=Default, ElementName=mySlider}"
ScaleY="{Binding Value, Mode=Default, ElementName=mySlider}" />
</Grid.RenderTransform>
<Label Content="Hello" Margin="10,5,10,0" />
<TextBlock Text="Howdy" Margin="20,20,20,10" />
<Slider x:Name="mySlider" Minimum="1" Maximum="10" Margin="30,35,30,20" />
</Grid>
</Page> Basically, this sample binds the render transformation of the grid to use a scale transform, bound to the slider called mySlider in the code. It really is that simple.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Does anyone know of a *free* Windows Explorer control? I already know about the "Shell MegaPack", but that's REALLY expensive...
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Sadly, no. We ended up writing our own version because we couldn't find one.
"WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
Well, I guess "Crap!" is the best response I can come up with.
"Why don't you tie a kerosene-soaked rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt, 1997 ----- "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001
|
|
|
|
|
Hi,
I have a Silverlight application in that one page i am having 1-8 videos will present.I placed each media element in seperate canvas. I want to fullscreen one particular media element with outer canvas.
For Full screen individula video I have written the following code
private
void FullscreenChange(object sender, RoutedEventArgs e)
{
if (SLHost.Content.IsFullScreen)
{
ToolTipService.SetToolTip(fullscreen, "Full Screen");
ms1.ScaleX = c;
ms1.ScaleY = d;
SLHost.Content.IsFullScreen = false;
}
else
{
ToolTipService.SetToolTip(fullscreen, "Resize");
ms1.ScaleX = ms1.ScaleX * 5.90;
ms1.ScaleY = ms1.ScaleY * 4.10;
SLHost.Content.IsFullScreen = true;
isFullScreen = true;
flag = false;
}
}
But here I am using same full screen button to resize video.If I use like this its working properly.But I dont want to use same button for Resize if I press Escape it will go to normal stage but its not working like that if I press Escape button it will go to noraml state but the video size is not reducing to original it is in bigger size only.Can you please guide me what is the mistake i have done.If I press Escape button it has to go to normal state and also it has to reduce the video size like previous size.
Thanks in Advance
Pavani
|
|
|
|
|