|
In silverlight map control, how do we specify the map source as "http://dev.mapindia.live.com/mapcontrol/mapcontrol.ashx?v=6.2"
There are examples on doing this in javascript, but not in silverlight...
http://dev.mapindia.live.com/sdk/[^]
<script type="text/javascript" src="http://dev.mapindia.live.com/mapcontrol/mapcontrol.ashx?v=6.2"></script>
|
|
|
|
|
hi
I want to use multiple grid on UserCotrol, how can i use??
any example??
thnxx
|
|
|
|
|
A very simple way to do this would be to place multiple grids inside another control.
For e.g.
<UserControl>
<StackPanel>
<Grid></Grid>
<Grid></Grid>
</StackPanel>
<UserControl/>
|
|
|
|
|
As Abhinav stated, you can host a Grid inside a StackPanel. It's important to realise that panels are content containers, so they can be laid out inside other panels just as easily as buttons or labels can. This means that you can be very flexible with the layout so that you can host grids inside grids inside stackpanels, and so on."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
I have a control inside a datagridtemplatecolumn (in the celleditingtemplate to be accurate, please find the bold line in the xaml below)
As I have multiple grids with multiple columns of this kind I search for a generic way to get the TextBox's binding (the property name "ItemName" ín this special case) when I have a handle to the template column in code.
Alternatively I could get the property from the column x:Name, but I did not manage this either
Any help would be appreciated...
Regards
Klaus
<dg:DataGridTemplateColumn x:Name="dbcItemName" Header="{Loc C_ItemName}" HeaderStyle="{StaticResource styFilterTextBoxColumn}">
<dg:DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<TextBlock Text="{Binding Path=ItemName, Mode=OneWay}"/>
</DataTemplate>
</dg:DataGridTemplateColumn.CellTemplate>
<dg:DataGridTemplateColumn.CellEditingTemplate>
<DataTemplate>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Stretch" >
<TextBox IsEnabled="{Binding IsNew}" MinWidth="30" Text="{Binding Path=ItemName, Mode=TwoWay}"/> <Button IsEnabled="{Binding IsNew}" x:Name="pbSelectItemName" Click="pbSelectItemName_Click" >...</Button>
</StackPanel>
</DataTemplate>
</dg:DataGridTemplateColumn.CellEditingTemplate>
</dg:DataGridTemplateColumn>
|
|
|
|
|
I don't quite understand your question.
A template is nothing more than a XAML fragment (i.e. a piece of text) until it is actually created.
In this case each DataGridRow create a UI component from the template.
Your question is probably wrong but a straight answer would be to enumerate the visual tree of the DataGrid until you find the collection of DataRow, and then look at the logical child UI control of each row (because the editing control is only a visual child when editing) to get the list of text boxes (1 per row), then you could work with the list of textboxes....A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Super Lloyd , thank you for answering,
Maybe I have to explain more detailed:
I have a datagrid which contains multiple "normal" datagridtextcolumns and multiple datagridtemplatecolumns, each of these have the datatemplate I described in the first post.
Additionally,each column has a filter textbox (lets call it txFilter) in the column header, that allows ... yes, filtering of the datagrid
Inside my filter functionality I have to retrieve the binding of the column in which I entered something in txFilter, which works fine for "normal" columns (as they are bound).
Datatemplatecolumns are different, because they are not bound but may contain more than one bound control, in my case it is exactly one textbox.
Now I am wondering how I can retrieve to which property the textbox in the datatemplatecolumn is bound
Hope you can help
Klaus
|
|
|
|
|
I have 2 answers to your problem:
1. you are doing it wrong! how do you know there is TextBox in your DataGridTemplateColumn? There might not be!
Perhaps you sould provide the binding to the property to filter on as an attached property to your header?
2. if you know there is going to be a some text in the column, you can use the VisualTreeHelper to explore the cell, until you find a TextBlock / TextElement / Run and extract its valueA train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Super Lloyd
I'd like to thank you for the support.
It was not clear to me how the datatemplate is used at runtime, so finding the textbox in the datatemplate is the wrong way, definitely.
Maybe there is a short cut for me, as I name my columns in a way that I can derive the binding from it ... but I cannot find the name (given using X:Name in Xaml) when I look into the column object during debug. Maybe I am doing something really wrong? So when please enlight me
Regards
Klaus
|
|
|
|
|
Why not use an attached dependency property on your column, such as "Filter.PropertyPath" on your column header?
Other than that the Name property should work, I wonder why it doesn't...A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Sorry for getting back but as "intermediate beginner in WPF" I think I still have difficulties with the concepts, but:
Regarding the name: I do not see that the class DataGridTemplateColumn (and the normal columns) has a property "Name", so where does "x:Name" go to then and how can I get it at runtime?
Regarding the attached property: The filtering controls are plumbed into the datagridheader using a controltemplate (unfortunately not constructed by me, I followed this article Filtering the WPF DataGrid automatically via the header (inline filtering)[])
Besides the difficulty to construct the binding of the attached property I see the problem that its (the attached propertie's) binding must somehow refer to the binding of the column (which does not exist in the case of the datagridtemplatecolumn), or am I completely wrong
Thanks for your support
Klaus
|
|
|
|
|
x:Name will end up in 2 places.
1 Some WPF classes have a name property (FrameworkElement and Style for exemple) and x:Name will set it.
2. also, in case of a code behind class, the XAML precompiler will generate member with the name in x:Name, provided they are at the top level naming scope (read INameScope documentation) (i.e. not in a template)
ex:
Window1.xaml
<Window
x:Class="WpfApplication1.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="Window1" Height="300" Width="300">
<Button x:Name="but" Content="Click"/>
</Window>
Window1.xaml.cs
public partial class Window1 : Window
{
public Window1()
{
InitializeComponent();
but.Click += (o, e) => MessageBox.Show("Button Clicked");
}
}
Other than that a Binding is made of 3 part, a PropertyPath, a source and a target.
The source is generally the DataContext (if not specified) and is different for each row in the grid. And the target is also different in each row (it's the cell) what you want is the PropertyPath, which can easily be set somewhere else.
mm.. reading the article... you are trying to implement UpdateFilter() and need to know the propertyName, are you?
how about you create an attached property in FilteringDataGrid called "FilterPath"?
you can use build in snippet in VS2005/2008, type "propa" followed by TAB, fill the blank!
Then when you declare your columns, set the property:
<dg:DataGridTemplateColumn
FilteringDataGrid.FilterPath="MyProperty"
x:Name="dbcItemName"
Header="{Loc C_ItemName}"
HeaderStyle="{StaticResource styFilterTextBoxColumn}">
<dg:DataGridTemplateColumn.CellTemplate>.....
...... A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
Super Lloyd
yes this works fine ... thanks for your help ...
Regards
Klaus
|
|
|
|
|
Super Lloyd
allow me to come back to you in this issue.
Using the attached property solves the problem of getting the property of the current column, that works fine now.
The reason for using DataGridTemplateColumns have been that I want to have columns in my DataGrid that contain not only a textbox but additional controls (like a button in my case). These are working fine now, but what always was a pain in my app is the lengthy xaml code that is used for the template columns.
Now I started an alternative approach: I derived a new column type from DataGridTextColumn, and I am right now trying to overwrite the GenerateEditingElement event to show a usercontrol (with a textbox and a button in it). This works ok but changes to the textbox text property are not going "back" in my datagrid.
Maybe you have an idea?
I am using this in my datagrid:
<local:DerivedColumn Header="Usercontrol" Binding="{Binding FirstName, Mode=TwoWay}"></local:DerivedColumn>
This is my usercontrol xaml:
<Grid x:Name="grid1" MaxHeight="25">
<Grid.ColumnDefinitions>
<ColumnDefinition />
<ColumnDefinition Width="25"/>
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="25"/>
</Grid.RowDefinitions>
<TextBox x:Name="txSelect" Text="{Binding UcText, Mode=TwoWay}" />
<Button x:Name="pbSelect" Background="Red" Grid.Column="1" Click="pbSelect_Click">...</Button>
</Grid>
... and the codebehind:
Public Class UcSelect
Private Shared Sub textChangedCallBack(ByVal [property] As DependencyObject, ByVal args As DependencyPropertyChangedEventArgs)
Dim UcSelectBox As UcSelect = DirectCast([property], UcSelect)
End Sub
Public Property UcText() As String
Get
Return GetValue(UcTextProperty)
End Get
Set(ByVal value As String)
SetValue(UcTextProperty, value)
End Set
End Property
Public Shared ReadOnly UcTextProperty As DependencyProperty = _
DependencyProperty.Register("UcText", _
GetType(String), GetType(UcSelect), _
New FrameworkPropertyMetadata(String.Empty, FrameworkPropertyMetadataOptions.BindsTwoWayByDefault, New PropertyChangedCallback(AddressOf textChangedCallBack)))
Public Sub New()
InitializeComponent()
grid1.DataContext = Me
End Sub
Private Sub pbSelect_Click(ByVal sender As System.Object, ByVal e As System.Windows.RoutedEventArgs)
'just demo
UcText = UcText + "!"
End Sub
End Class
And now the derived column:
Public Class DerivedColumn
Inherits DataGridTextColumn
Protected Overloads Overrides Function GenerateElement(ByVal oCell As DataGridCell, ByVal oDataItem As Object) As FrameworkElement
Dim oElement = MyBase.GenerateElement(oCell, oDataItem)
Return oElement
End Function
Protected Overloads Overrides Function GenerateEditingElement(ByVal oCell As DataGridCell, ByVal oDataItem As Object) As FrameworkElement
Dim oUc As New UcSelect
Dim oBinding As Binding = CType(Me.Binding, Binding)
oUc.SetBinding(UcSelect.UcTextProperty, oBinding)
Return oUc
End Function
End Class
This shows me the correct data, but changes are ignored (the are rolled back when leaving the grid cell)
Any help would be appreciated
Klaus
|
|
|
|
|
Just an educated guess here, but maybe you can write your user control like that:
.....
<TextBox x:Name="txSelect" Text="{Binding UcText, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" />
.....
TextBox, by default, only update the source on focus lost, and because the UI editing control is removed from the hierarchy probably before the focus lost event, maybe the binding is never triggered....
hence the additional UpdateSourceTrigger in the Binding definition
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
This does not help.
Maybe the problem is not datagrid specific but because it is a itemscontrol? So maybe you know an example where a usercontrol with binding is used in a itemscontrol?
Regards
Klaus
|
|
|
|
|
I just saw something else...
You user control's text...at least on what you wrote, isn't binded to any data!
the TextBox seems to be binded to the UtcText property of the user control...
but do you bind this UtcText property 2 way to your data as well?
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
I do not see your point ... but to some degree I am quite lost with the double bindings in here ... one question: would it be impolite to send you a small project which isolates the problem and where you can take a look "lively" ?
Thanks for your time and effort
Klaus
|
|
|
|
|
hmm.. oke doke...
be aware that I'm rather sick this month and not overtly productive....
my email is "L D buzz at galador word dot net", remove space and buzz word!
A train station is where the train stops. A bus station is where the bus stops. On my desk, I have a work station....
_________________________________________________________
My programs never have bugs, they just develop random features.
|
|
|
|
|
I'm relatively new to C# and have just started playing around with WPF. As a start I decided to make a simple calculator. I added one of the permade textboxes to take input from the user, but you can't perform addition, subbtraction, and so on, oporations on a string, and it won't let me typecast the string to another type like double. How can I change the textbox input to something I can use, or what is there some other object I can use to get the input?
|
|
|
|
|
You can't cast a string to a number but you can convert it. Any of these will work
string num = "1";
int.Parse(num);
int numOut = 0;
int.TryParse(num, out numOut);
Convert.ToInt32(num); I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Even with each of those lines it still tells me it can't convert from string to int.
in case its signifigant, I'm using Visual Studio 2008 btw.
|
|
|
|
|
You are quite obviously doing something incorrectly, each of those lines is accurate.
Post what you are doing? and please don't forget to format it properly, i.e. use pre tags I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Sorry to take more of your time. I've figured out what I did wrong and have gotten it working now.
|
|
|
|
|
Can you please share code?
|
|
|
|