|
i want to implement audio bars in mediaelemnt ...
|
|
|
|
|
I dont understand, could you expalain or elaborate?
|
|
|
|
|
I am trying to create a reasonably complex datagrid.
At the core, there are sting pairs where the first string is the key and the second is the value.
I make 2 passes through the base array. Don't try to understand the base array, just accept that 2 strings, key and value, are extracted.
On the first pass, the datagrid has columns dynamically created. The column names works as expected. I believe the binding is not correct.
Once all know possible columns are known, the second pass extracts the key/value pairs from the original table and composes a dictionary called "person".
The original table is a 2 dimensional table, first an array of key/values of dynamic length then a dynamic number of such arrays.
Each dictionary is added to a List called "persons"
If a particular key is not found in the base table, the value "_" is assigned.
Finally the datagrid.itemsource is assigned the list "persons".
When the datagrid is displayed, the column names are correct.
The number of columns is correct.
The number of rows is correct but blank.
The debugger output window shows a flurry of error messages such as:
==========
System.Windows.Data Error: BindingExpression path error: 'mv' property not found on 'System.Dynamic.ExpandoObject' 'System.Dynamic.ExpandoObject' (HashCode=60469192). BindingExpression: Path='mv' DataItem='System.Dynamic.ExpandoObject' (HashCode=60469192); target element is 'System.Windows.Controls.TextBlock' (Name=''); target property is 'Text' (type 'System.String')...
======
Note that "mv" is one of the column names.
When I display the "persons" list using the debugger dynamicview for "persons" it does show the column name "mv" with the correct value.
The xaml:
===
<controls:ChildWindow x:Class="VCI_Envision_Portal.Views.LegacyGraphicDisplay.BackgroundDataxaml"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:controls="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls"
xmlns:data="clr-namespace:System.Windows.Controls;assembly=System.Windows.Controls.Data"
Width="400" Height="300"
Title="BackgroundDataxaml"
xmlns:sdk="http://schemas.microsoft.com/winfx/2006/xaml/presentation/sdk"
>
<Grid x:Name="LayoutRoot" Margin="2">
<Grid.RowDefinitions>
<RowDefinition />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
<Button x:Name="CancelButton" Content="Cancel" Click="CancelButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,0,0" Grid.Row="1" />
<Button x:Name="OKButton" Content="OK" Click="OKButton_Click" Width="75" Height="23" HorizontalAlignment="Right" Margin="0,12,79,0" Grid.Row="1" />
<data:DataGrid AutoGenerateColumns="True" Height="226" HorizontalAlignment="Left" Name="BackgroundDataGrid" VerticalAlignment="Top" Width="372" />
</Grid>
</controls:ChildWindow>
===
the xaml.cs:
====
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using System.Collections;
using System.Collections.ObjectModel;
using System.Windows.Data;
using System.Dynamic;
using Microsoft.CSharp;
using Microsoft.CSharp.RuntimeBinder;
using VCI_Envision_Portal.VCIWCFServicesNS;
namespace VCI_Envision_Portal.Views.LegacyGraphicDisplay
{
public partial class BackgroundDataxaml : ChildWindow
{
private ObservableCollection<VCI_Point_Data[]> vci_pt_data_cooked_bg = new ObservableCollection<VCI_Point_Data[]>();
List< ExpandoObject > persons;
public BackgroundDataxaml(VCI_Point_Data[][] vci_pt_data_cooked_in)
{
int i;
for (i = 0; i < vci_pt_data_cooked_in.Length; i++)
{
vci_pt_data_cooked_bg.Add(vci_pt_data_cooked_in[i]);
}
InitializeComponent();
SetPageValues();
}
private void SetPageValues()
{
int index = 0;
RowDefinition rd = new RowDefinition();
persons = new List<ExpandoObject>();
ObservableCollection<Customer> bdd = new ObservableCollection<Customer>();
int iCount = vci_pt_data_cooked_bg.Count();
while (index < iCount)
{
int iColumnCount = 0;
DataGridRow dgr = new DataGridRow();
if (vci_pt_data_cooked_bg[index] != null)
{
int iColumns = vci_pt_data_cooked_bg[index].Count();
while (iColumnCount < iColumns)
{
if (vci_pt_data_cooked_bg[index][iColumnCount] != null)
{
Customer bob = new Customer();
bob.FieldName = vci_pt_data_cooked_bg[index][iColumnCount].Pt_Column;
bob.FieldValue = vci_pt_data_cooked_bg[index][iColumnCount].Pt_Value;
bdd.Add(bob);
{
int i = 0;
bool bFound = false;
for (i = 0; (i < BackgroundDataGrid.Columns.Count) && !bFound; i++)
{
if (BackgroundDataGrid.Columns[i].Header.Equals(bob.FieldName))
bFound = true;
}
if (!bFound)
{
DataGridTextColumn mycol = new DataGridTextColumn
{
Header = bob.FieldName,
Binding = new Binding( bob.FieldName )
};
BackgroundDataGrid.Columns.Add( mycol );
}
}
}
iColumnCount++;
}
}
index++;
}
iCount = vci_pt_data_cooked_bg.Count();
ObservableCollection<DataGridColumn> dgc = BackgroundDataGrid.Columns;
index = 0;
while (index < iCount)
{
int iCols = 0;
var aperson = new ExpandoObject() as IDictionary<string, Object>;
while (iCols < dgc.Count())
{
bool bFound = false;
int y = 0;
string skey = dgc[iCols].Header.ToString();
if ( vci_pt_data_cooked_bg[index] != null )
{
while ( (y < vci_pt_data_cooked_bg[index].Length) && !bFound )
{
if (vci_pt_data_cooked_bg[index][y].Pt_Column.Equals(skey ) )
{
bFound = true;
aperson.Add( skey, vci_pt_data_cooked_bg[index][y].Pt_Value );
}
y++;
}
if (!bFound)
{
aperson.Add(skey, "_");
}
}
iCols++;
}
index++;
persons.Add((ExpandoObject)aperson);
}
BackgroundDataGrid.ItemsSource = persons;
}
private void OKButton_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = true;
}
private void CancelButton_Click(object sender, RoutedEventArgs e)
{
this.DialogResult = false;
}
public class Customer
{
public string FieldName { get; set; }
public string FieldValue { get; set; }
}
}
}
===
I think the binding is wrong.
But this is the best I could decipher from online examples.
Please advise.
Boyd
Boyd D. Mills
mailto:BMills@VCIControls.ca
|
|
|
|
|
I have a WPF project and I have added a user control but when I try to add the xmlns of the user control to the MainWindow xaml, nothing shows up in the intellisense what am I missing here. Thanks.
|
|
|
|
|
I think I found a solution to this. I just selected the first namespace that had the same name as my project. My project name is ParametricModeler. So I typed:
xmlns:local="" and selected the option ParametricModeler(ParametricModeler). So that I have
xmlns:local="clr-namespace:ParametricModeler" That let me add the user control I made to the MainWindow.
<Grid>
...
<local:Calculator/>
</Grid>
I was working from a youtube video: [^]
But this is not the way xmlns namespace was selected in the example video. The name of the UserControl was added to the namespace options list after the project was rebuilt. But I could not get that option and I tried several times with different projects. He was using a different version of Visual Studio would that mater? Did I do good? I am using VS 2012.
Also how do you add a property to a user control if you are coding in Visual Basic?
|
|
|
|
|
tomr1 wrote: xmlns:local="clr-namespace:ParametricModeler"
You need to add a local reference to your class / dll.
So this is indeed correct.
|
|
|
|
|
Thanks Abhinav S. I have a kind of related question about how to get access to the MainWindow resources from the UserControl. I have the MainWindow code:
<Window
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:ParametricModeler"
...>
<Window.Resources>
...
</Window.Resources>
</Window>
Then in the UserControl I do not know how to access those resources. For instance I have a Gradient Brush that I am trying to apply to the control but its key is not recognized:
<UserControl x:Class="Calculator"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
...>
<Grid x:Name="CalculatorControl">
<Rectangle Fill="{StaticResource ButtonBrush}" RadiusX="10" RadiusY="10"/>
...
</Grid>
</UserControl>
The error reads, "The resource "ButtonBrush" could not be resolved".
|
|
|
|
|
The reason the UserControl can't access the gradient brush is because it's a Window resource. If it was a userControl resource, <UserControl.Resources> , then you wouldn't be getting the error. Alternatively you could place the gradient brush in a ResourceDictionary .
"As beings of finite lifespan, our contributions to the sum of human knowledge is one of the greatest endeavors we can undertake and one of the defining characteristics of humanity itself"
|
|
|
|
|
i am looking for windowmedia format sdk that works with silverlight.
|
|
|
|
|
I have a WPF project where I have a main grid and inside that I have some basic 3D elements for basic 3D modeling of points in time(like a 3D grapher). I am using a seperate library for the 3D stuff. I added basic tools like a calculator and a timer control and other controls. These controls consist of a grid and inside that grid is a rectangle control and some textboxes and buttons. I do not know how to make the grids be dragable like a regular window. Is there a simple method for this?
I am using Visual Studio Express Edition 2012. I program in Visual Basic. Thanks for your help.
modified 25-Jun-13 23:51pm.
|
|
|
|
|
Canvas would allow your costume grid to be drag-able.
To add Grid on to Canvas :
var canvas = new Canvas();
var grid = new YourCustomeGrid();
canvas.Children.Add(grid);
To set grid position on the canvas :
grid.SetValue(Canvas.TopProperty, 20.0);
grid.SetValue(Canvas.LeftProperty, 20.0);
Then you just have to Add Eventhandler for your control to change the position when your drag your mouse.
|
|
|
|
|
Thanks for the reply sorawit amorn. Sorry about the delay.
So I made a new project to focus on just this dragging issue. I am not great with C# but I get most of what you have there. I declared a canvas and a grid inside that canvas in the xaml code of the main window. In the behind VB code I created a loaded event handler with the initial grid positions.
Here is the Main Window code:
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Canvas x:Name="ControlCanvas" Background="AliceBlue" >
<Grid x:Name="ControlGrid" Width="100" Height="40">
<Rectangle Fill="Black"/>
</Grid>
</Canvas>
</Grid>
</Window>
And here is the MainWindow.xaml.vb code:
Class MainWindow
Private Sub MainWindow_Loaded(sender As Object, e As RoutedEventArgs) Handles Me.Loaded
ControlGrid.SetValue(Canvas.TopProperty, 20.0)
ControlGrid.SetValue(Canvas.LeftProperty, 20.0)
End Sub
Private Sub MainWindow_MouseLeftButtonDown(sender As Object, e As MouseButtonEventArgs) Handles Me.MouseLeftButtonDown
End Sub
End Class
I have no idea how to write in code what I need to do next. I need a conditional statement for when the mouse is over the grid control. Then I need to get the position of the cursor and somehow update the position of the control simultaneously. How do I do that? Thanks again.
|
|
|
|
|
you will have the object to hold your grid references when you click on and the you can define MouseMove event of you canvas to set new position every time the event trigger.
I don't remember VB syntax, but on c#, It will be ...
Code
Grid mygrid;
private MouseButtonEvent MouseLeftButtonDown(Object sender, MouseButtonEventArgs e){
grid = sender as Grid;
if(grid!= null){
mygrid = grid;
}
}
private MouseEventHandler MoveChildObject(Object sender, MouseEventHandler e){
if(mygrid != null){
Point p = Mouse.GetPosition(canvas);
ControlGrid.SetValue(Canvas.TopProperty, p.Y);
ControlGrid.SetValue(Canvas.LeftProperty, p.X);
}
}
private MouseButtonEvent mouseLeave(Object sender, MouseButtonEventArgs e){
mygrid = null;
}
XMAL
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Canvas x:Name="ControlCanvas" Background="AliceBlue" MouseOver="MoveChildObject" >
<Grid x:Name="ControlGrid" Width="100" Height="40" MouseLeftButtonUp="mouseLeave" MouseLeftButtonDown="MouseLeftButtonDown" >
<Rectangle Fill="Black"/>
</Grid>
</Canvas>
</Grid>
</Window>
NOTE :: you do not need to use grid, if you just use it for holding the rectangle. Just use rectangle object
|
|
|
|
|
you will have the object to hold your grid references when you click on and the you can define MouseMove event of you canvas to set new position every time the event trigger.
I don't remember VB syntax, but on c#, It will be ...
Code
Grid mygrid;
private MouseButtonEvent MouseLeftButtonDown(Object sender, MouseButtonEventArgs e){
grid = sender as Grid;
if(grid!= null){
mygrid = grid;
}
}
private MouseEventHandler MoveChildObject(Object sender, MouseEventHandler e){
if(mygrid != null){
Point p = Mouse.GetPosition(canvas);
ControlGrid.SetValue(Canvas.TopProperty, p.Y);
ControlGrid.SetValue(Canvas.LeftProperty, p.X);
}
}
private MouseButtonEvent mouseLeave(Object sender, MouseButtonEventArgs e){
mygrid = null;
}
XMAL
<Window x:Class="MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="MainWindow" Height="350" Width="525">
<Grid>
<Canvas x:Name="ControlCanvas" Background="AliceBlue" MouseOver="MoveChildObject" >
<Grid x:Name="ControlGrid" Width="100" Height="40" MouseLeftButtonUp="mouseLeave" MouseLeftButtonDown="MouseLeftButtonDown" >
<Rectangle Fill="Black"/>
</Grid>
</Canvas>
</Grid>
</Window>
NOTE :: you do not need to use grid, if you just use it for holding the rectangle. Just use rectangle object
|
|
|
|
|
Hello, I know this is a silly question but i am stunned by this. Among controls that I use like DecimalUpDown (From WPF toolkit), textboxes and comboboxes.
For all controls that are required to be filled, I have set the background color to LightYellow. I am not so successful, because i am failing to applay to combobox. No matter what background property is, Combo box ignores/overrides it.
I do not wan't to change any apperances of any ComboBoxItems. Also Since i need it on Windows XP, my Framework target is 4.0
Any help is appreciated.
modified 23-Jun-13 5:24am.
|
|
|
|
|
I don't have an answer but by entering your question into google it seems to have been answered many times, including a tip[^] here on CP.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
On google all i could find how to change drop down box when i click on combo box. Same goes for that link on CP. And i do not need that. I wanted a backgroud color changed directly on combobox and not on the drop down list.
Upon further investigation by WPF inspecotrs I found that there is a specific background property on the child visual tree
ComboBox
Grid(templateRoot)
Popup (PART_Popup)
ToggleButton (toggleButton)
Border (templateRoot)
Border (splitBorder)
Path (Arrow)
ContentPresenter (contentPresenter)
TextBlock
I Have to change templateRoot background property. But i do not know how. I am noob at WPF
|
|
|
|
|
Now you are beyond where I have ventured, especially as I work in Silverlight but I believe you need to completely restyle the combo to get what you want. Some use Expression Blend that will allow you to grab the controls style and fiddle with it, not something I would contemplate doing.
I'm a great believer in battleshit grey and would never get hung up about the colour of an objects styling.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I was searching for a tool that is capable extracting Styles/Theme. I know it exsist, because i had it a few years ago. I tried VS2012 And Blend. What i noticed is that when using create a copy of style is not a perfect. I am using it on Windows 8 and border has sharp edges, and when applying a copy of a style, my controls border get rounded. On top of all when i creadet a copy, my background property took an effect i wanted it to do in the first place, without modifiying style??? I was realy suprised by this.
I got it working. Thanks for sugestion.
|
|
|
|
|
Check if someone has already reported this issue on codeplex. Could be an issue.
You could first try setting the back color via the view model though.
|
|
|
|
|
Not an issue. I also found out what to change with WPF inspector. But i do not know how. I replied to Mycroft Holmes with detail on what to change.
|
|
|
|
|
I have been able to locate styles for a number of controls on msdn.
You can give it a try next time onwards.
The toolkit is opensource, so you could get the styles directly via code.
|
|
|
|
|
Someone at work coded an attached behavior and it has code like this.
if (dataSource.GetType() == typeof(TypeA))
((TypeA)dataSource).PropertyXYZ.MethodOne();
else if (dataSource.GetType() == typeof(TypeB))
((TypeB)dataSource).MethodOne();
else if (dataSource.GetType() == typeof(TypeC))
((TypeC)dataSource).MethodOne();
In this schenario, is it Okay for attached behaviours to have knowledge of viewModels or Is it best to extract an interface/base type out and act on that?
Cheers,
Suresh
|
|
|
|
|
Let the attached behavior have knowledge of a controller rather than individual view models.
Let the controller know about the view models.
|
|
|
|
|
I suggested to extract a common interface out and let the behavior have the knowledge of this interface than multiple viewmodels - but that suggestion was shot down saying it's a matter of taste
Cheers,
Suresh
|
|
|
|