|
How did you pop the windows, button or mouse over?
This is another option I am considering as there is a lot of looking but not a great deal of modification after the object is created.
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I'd pop the window on demand (e.g. F4 or a right-mouse click while a data-entry field has focus) or on trying to exit the field after typing an invalid entry. The intent was to minimize key strokes and mouse moves and maintain flow.
modified 27-Nov-15 20:37pm.
|
|
|
|
|
<ListView x:Name="lvBookings" VirtualizingStackPanel.IsVirtualizing="True" MinHeight="300" MinWidth="850" ItemsSource="{Binding ListViewItemsCollections}" Grid.Row="1" Grid.Column="0" Grid.ColumnSpan="2">
<ListView.View>
<GridView AllowsColumnReorder="False">
<GridViewColumn Header="Venue" Width="100" DisplayMemberBinding="{Binding Venue}"/>
<GridViewColumn Header="Date" Width="100" DisplayMemberBinding="{Binding Date}"/>
<GridViewColumn Header="Status" Width="100" DisplayMemberBinding="{Binding Status}"/>
<GridViewColumn Header="Duration" Width="100" DisplayMemberBinding="{Binding Duration}"/>
<GridViewColumn Header="TimeIn" Width="100" DisplayMemberBinding="{Binding TimeIn}"/>
<GridViewColumn Header="TimeOut" Width="100" DisplayMemberBinding="{Binding TimeOut}"/>
<GridViewColumn Header="Progress" Width="100">
<GridViewColumn.CellTemplate>
<DataTemplate>
<ProgressBar Name="pbDuration" Value="{Binding ProgressValue}" Minimum="0" Maximum="{Binding MaxValue}" Width="100"/>
</DataTemplate>
</GridViewColumn.CellTemplate>
</GridViewColumn>
</GridView>
</ListView.View>
</ListView>
modified 22-Nov-15 7:40am.
|
|
|
|
|
It would depend, I believe, on how you want to use it. If you are trying to set its visible property, for example, you might try the "Path=" or the ElementName= syntax. I am pretty new to WPF but accessing child controls of the element tree ought to be the same as when you need to bind to another element.
I hope this helps. As I said, I am sort of a beginner.
Joey
Joseph M. Morgan
|
|
|
|
|
So I'm learning about Routed Events. I just found this[^] excellent blog post.
I understand what it does, but why not just do this:
public delegate void ButtonWasClickedEventHandler();
public event ButtonWasClickedEventHandler ButtonWasClicked;
private void raiseButtonWasClicked()
{
if (ButtonWasClicked != null)
{
ButtonWasClicked();
}
}
and then in the parent control:
<local:ChildControl Margin="61,87,108,95"
ButtonWasClicked="ChildControl_ButtonWasClicked"/>
and
private void ChildControl_ButtonWasClicked()
{
}
Basically, I don't see the point of the routed event. A Standard event works fine.
If it's not broken, fix it until it is
|
|
|
|
|
|
Hi,
I want to change silverlight 4 datepicker format as 'dd/MM/yyyy' in one page only. I tried below code
Thread.CurrentThread.CurrentCulture = (CultureInfo)Thread.CurrentThread.CurrentCulture.Clone();
Thread.CurrentThread.CurrentCulture = (CultureInfo)Thread.CurrentThread.CurrentCulture.Clone();
Thread.CurrentThread.CurrentCulture.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy";
But It changes format in whole silverlight application. I want datepicker change format in one silverlight page only.
Please give me solution.
Thanks.
Regards,
Suchita Gorivale
|
|
|
|
|
You need to include Stringformat in the binding xaml.
{Binding YourDateField, StringFormat='dd/MM/yyyy'}
Take a read of this article[^]
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
I want my button to be enable only when one item in listbox is checked else disable the button. how to achieve this? Any help please
<ListBox Name="listBoxDraftVersions" Height="200" Width="250" Margin="3" ItemsSource="{Binding DraftList}">
<ListBox.ItemTemplate>
<DataTemplate>
<Border x:Name="TheBorder" BorderBrush="Gray" BorderThickness="1" Padding="4" CornerRadius="4" Margin="2">
<CheckBox Name="radioButZone" Content="{Binding DraftName}" IsChecked="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type ListBoxItem}}, Path=IsSelected}"></CheckBox>
<Border.Background>
<LinearGradientBrush EndPoint="0.5,1" StartPoint="0.5,0">
<GradientStop Color="AliceBlue" Offset="0.15" />
<GradientStop Color="White" Offset="0.85" />
<GradientStop Color="Lavender" Offset="1" />
</LinearGradientBrush>
</Border.Background>
</Border>
</DataTemplate>
</ListBox.ItemTemplate>
</ListBox>
<Button Content="Load" IsDefault="True" x:Name="btnLoad" Style="{StaticResource MetroButton}" Click="btnLoad_Click" />
i tried
IsEnabled="{Binding ElementName=listBoxDraftVersions, Path=IsSelected}" not working
|
|
|
|
|
Add a DataTrigger to your Button; e.g.
<Button Content="Load"
IsDefault="True"
x:Name="btnLoad"
Click="btnLoad_Click">
<Button.Style>
<Style TargetType="Button">
<Style.Triggers>
<DataTrigger Binding="{Binding ElementName=listBoxDraftVersions, Path=SelectedItems.Count}"
Value="0">
<Setter Property="IsEnabled"
Value="False" />
</DataTrigger>
</Style.Triggers>
</Style>
</Button.Style>
</Button>
|
|
|
|
|
Hi Gerry,
Thanks for your quick reply , same thing is happening if i use
IsEnabled="{Binding ElementName=listBoxDraftVersions, Path=SelectedItems.Count}" on button.
But i want button to be enabled when only 1 checkboox is checked else it should be diabled if >1 and <1
Thanks and Regards
|
|
|
|
|
"IsEnabled" is a bool; simply trying to bind it to SelectedItems.Count (an int) is not going work.
You might be able to use a "converter" in there ...
(Or just change the trigger to "enable" the button if the "count" is 1; using a default of "not enabled").
|
|
|
|
|
Hi Gregg,
In that case i am not able to select multiple checkboxes. i want to select multiple checkboxes also but using this cannnot select multiple only one is getting checked at one time.
Thanks
|
|
|
|
|
To select multiple items, the "SelectionMode" for the ListBox should be set to "Multiple".
If you are going to ignore the "built-in" selection logic of the ListBox and associated items, then you will have to use your own custom code.
Your approach is wrong.
Your are using checkboxes to "select" items in a listbox; instead, you should simply use the checkbox to "display" the "selected" status of a given item and use the built-in selection logic as it was intended.
(Gary, Larry, Gerald, George and now Gregg ... My level of visibility is now tracking in the minus range).
|
|
|
|
|
I'm trying to bind the ListBoxItem's IsSelected property to a property called 'IsItemSelected' on my base entity.
<Style x:Key="listBoxItemContainerStyle"
TargetType="ListBoxItem">
<pre>
<Setter Property="IsSelected" Value="{Binding IsItemSelected}"/>
This isn't working. The selected item's IsItemSelected property is not being set.
What am I missing here?
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
A couple of ideas, first what is the listbox items source? Make sure that the object in the items source should have a boolean property "IsItemSelected" and that would be the property that you bind the value to, not the view model.
I made a sample object that had two properties, string Name and bool IsItemSelected
I added that to an observable collection (yourList) and then I define the ListBox and the container style as such
<ListBox ItemSource="{Binding yourList}" DisplayMemberPath="Name">
<ListBox.ItemContainerStyle>
<Style TargetType="{x:Type ListBoxItem}">
<Setter Property="IsSelected"
Value="{Binding IsItemSelected}"/>
If this is not working then the fault might be in your view model, things to make sure are are you implementing INotifyPropertyChanged? Is your event set up correctly? If this is still not working and you would like to post your view model I would be happy to help.
Cheers!
|
|
|
|
|
I have one datagrid, inside that datagrid have taken one combobox. I am trying to create the SelectionChanged event for this combobox but its not working. Below is the code:
<DataGridTemplateColumn.CellTemplate>
<DataTemplate>
<Grid>
<StackPanel Orientation="Horizontal">
<cc:MyComboBox Name="ddlDepositMode" Width="150" ItemsSource="{Binding DataContext.ModeCollection, Mode=TwoWay, RelativeSource={RelativeSource AncestorType={x:Type UserControl}}}" DisplayMemberPath="ModeName" SelectedValuePath="ModeId" IsSynchronizedWithCurrentItem="False" SelectedValue="{Binding Path=ModeId,Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" SelectedItem="{Binding Path=ModeName, Mode=TwoWay,UpdateSourceTrigger=PropertyChanged}" Padding="3,0,0,0">
<i:Interaction.Triggers>
<i:EventTrigger EventName="SelectionChanged">
<i:InvokeCommandAction Command="{Binding DataConext.ModeTypeCommand, RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type UserControl}}}" />
</i:EventTrigger>
</i:Interaction.Triggers>
</cc:MyComboBox>
</StackPanel>
</Grid>
</DataTemplate>
</DataGridTemplateColumn.CellTemplate>
|
|
|
|
|
Ashfaque Hussain wrote: DataConext.ModeTypeCommand
Shouldn't that be DataContext.ModeTypeCommand ?
If it still doesn't work, check the Output window in Visual Studio for binding errors.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have taken checkbox on the header of the DataGrid, but Boolean property of IsChecked is binding.
<DataGridTemplateColumn.HeaderTemplate>
<DataTemplate>
<StackPanel>
<cc:MyCheckBox Width="30" IsChecked="{Binding Path=MyViewModel.IsAllSelected, Mode=TwoWay, UpdateSourceTrigger=PropertyChanged}" ></cc:MyCheckBox>
</StackPanel>
</DataTemplate>
</DataGridTemplateColumn.HeaderTemplate>
|
|
|
|
|
Check the output window in Visual Studio for binding errors.
The Path=MyViewModel.IsAllSelected doesn't look right. Does the DataContext for the grid's parent really have a property called MyViewModel ? Are you sure it shouldn't just be Path=IsAllSelected ?
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have tried with all the possibilities for the Path property:
Path=DataContext.IsAllSelected
Path=IsAllSelected
Path=MyViewModel.IsAllSelected
none of these are working
|
|
|
|
|
Try doing it like this,
...
<cc:MyCheckBox Width="30" IsChecked="{Binding Path=IsAllSelected, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}">
...
"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"
|
|
|
|
|
Thanks Meshack, but this approach is not working
|
|
|
|
|
I overlooked something. It should be DataContext.IsAllSelected . This should work,
<cc:MyCheckBox Width="30" IsChecked="{Binding Path=DataContext.IsAllSelected, RelativeSource={RelativeSource AncestorType={x:Type DataGrid}}">
"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"
|
|
|
|
|
Hello Everyone,
I am facing issue in binding data to my controls. I am not able to implement below 2 scenarios:
1) whenever i am updating my textbox text my view model is not listening the change.
2) i also want to update my other 2 textbox text property based on the value of first textbox.
Kindly help me on this one.
here is my View
<Window x:Class="iPLAN20.Windows.LS.frmLinkApplicationSite"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns ="http://schemas.microsoft.com/expression/blend/2008"
xmlns:wf="clr-namespace:System.Windows.Forms;assembly=System.Windows.Forms"
xmlns:local="clr-namespace:iPLAN20.Model.LS"
xmlns:stb="clr-namespace:UIControls;assembly=iPLAN20UIControls"
Title="Link Information" Height="260" Width="320" Loaded="Window_Loaded" ResizeMode="NoResize" WindowStartupLocation="CenterScreen">
<Window.Resources>
<local:clsAppSiteLinkModel x:Key="AppSiteModel"/>
</Window.Resources>
<Grid HorizontalAlignment="Left" Name="gridLandSafeguardingLink" DataContext="{StaticResource AppSiteModel}">
<Grid.Resources>
<ResourceDictionary>
<ResourceDictionary.MergedDictionaries>
<ResourceDictionary Source="..\..\Resources\ButtonStyle.xaml"/>
<ResourceDictionary Source="..\..\Resources\textbox.xaml"/>
<ResourceDictionary Source="..\..\Resources\Common.xaml"/>
<ResourceDictionary Source="..\..\Resources\ComboBox.xaml"/>
</ResourceDictionary.MergedDictionaries>
</ResourceDictionary>
</Grid.Resources>
<Grid.ColumnDefinitions>
<ColumnDefinition Width="auto" />
<ColumnDefinition Width="auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
<RowDefinition Height="auto" />
</Grid.RowDefinitions>
<Label Content="Site No.:" HorizontalAlignment="Left" VerticalAlignment="Center" Style="{StaticResource ASCIILabelStyle}" Grid.Row="0" Grid.Column="0"/>
<StackPanel Orientation="Horizontal" HorizontalAlignment="Left" VerticalAlignment="Center" Grid.Row="0" Grid.Column="1">
<TextBox Text="{Binding Path=AppSiteList, UpdateSourceTrigger=PropertyChanged, Mode=OneWayToSource}" stb:AutoCompleteBehavior.AutoCompleteItemsSource="{Binding AppSiteList}" AutoWordSelection="True" Width="190" Name="txtSearchAppSite" TextAlignment="Center" Margin="10,4,4,4" VerticalContentAlignment="Center" Grid.Column="1"/>
<Button IsDefault="True" x:Name="btnFind" Style="{StaticResource MetroButton}" Margin="1" Width="30" Height="30">
<Button.Content>
<StackPanel Orientation="Horizontal">
<Image Source="/IPLAN20;component/Images/Search.png" Width="12"/>
</StackPanel>
</Button.Content>
</Button>
</StackPanel>
<Label Grid.Row="1" Grid.Column="0" Style="{StaticResource ASCIILabelStyle}" Content="Choose Site:" HorizontalAlignment="Left" VerticalAlignment="Center"/>
<ComboBox Grid.Row="1" Grid.Column="1" Style="{StaticResource ComboBoxStyle}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,4,4,4" Width="220" ItemsSource="{Binding LinkOID}"></ComboBox>
<Label Grid.Row="2" Grid.Column="0" Style="{StaticResource ASCIILabelStyle}" Content="Status:" HorizontalAlignment="Left" VerticalAlignment="Center"/>
<TextBox x:Name="txtStatus" Width="220" Grid.Row="2" Grid.Column="1" Style="{StaticResource TextBoxStyle}" HorizontalAlignment="Left" VerticalAlignment="Center" Margin="10,4,4,4" Text="{Binding AppSiteListColl[0].AppSiteStatus}"/>
<Label Grid.Row="3" Grid.Column="0" Style="{StaticResource ASCIILabelStyle}" Content="Description:" HorizontalAlignment="Left" VerticalAlignment="Center"/>
<TextBox x:Name="txtDescription" Height="100" Grid.Row="3" Grid.Column="1" Style="{StaticResource TextBoxStyle}" TextWrapping="Wrap" AcceptsReturn="True" VerticalScrollBarVisibility="Auto" Margin="10,4,4,4" Text="{Binding AppSiteListColl[0].AppSiteDescription}" />
<StackPanel Orientation="Horizontal" HorizontalAlignment="Center" Grid.Row="4" Grid.Column="1">
<Button Content="Link" IsDefault="True" x:Name="btnLink" Style="{StaticResource MetroButton}"/>
<Button Content="Close" IsDefault="False" x:Name="btnCancel" Style="{StaticResource MetroButton}"/>
</StackPanel>
<!--<WindowsFormsHost>
<wf:ListBox x:Name="lstBox"/>
</WindowsFormsHost>-->
</Grid>
</Window>
and my view model
class clsAppSiteLinkModel:INotifyPropertyChanged
{
public event PropertyChangedEventHandler PropertyChanged;
clsLandSafeguarding objLandSafeguarding = new clsLandSafeguarding();
private ObservableCollection<string> _collAppSiteListForLink = new ObservableCollection<string>();
private ObservableCollection<clsSearchAppSiteLink> objObCollAppSiteForLink = null;
public ObservableCollection<string> AppSiteList
{
get { return _collAppSiteListForLink; }
set
{
_collAppSiteListForLink = value;
FirePropertyChanged("AppSiteList");
}
}
public ObservableCollection<clsSearchAppSiteLink> AppSiteListColl
{
get { return objObCollAppSiteForLink; }
}
private ObservableCollection<string> _collOID = new ObservableCollection<string>();
ObservableCollection<clsObjectId> objObCollOID = null;
public ObservableCollection<string> LinkOID
{
get { return _collOID; }
}
public clsAppSiteLinkModel()
{
if (iPLANConstants.Instance.Workspace == null)
{ return; }
objObCollAppSiteForLink = objLandSafeguarding.GetAppSiteForLink();
//Selecting Application site No's from MV_IPLAN_EPACS
if (objObCollAppSiteForLink != null)
{
foreach (clsSearchAppSiteLink appSiteNo in objObCollAppSiteForLink)
{
this.AppSiteList.Add(appSiteNo.AppSiteNo);
}
}
objObCollOID = objLandSafeguarding.GetNewSiteOID();
//Selecting feature OID's from file geodatabase
if (objObCollOID != null)
{
foreach (clsObjectId objctID in objObCollOID)
{
this.LinkOID.Add(objctID.ObjectIds);
}
}
}
private void FirePropertyChanged(string propertyName)
{
if (PropertyChanged != null)
{
PropertyChanged(this, new PropertyChangedEventArgs(propertyName));
}
}
}
whenever txtSearchAppSite text gets changed based on the value txtStatus and txtDescription changed their values. All data is there under objObCollAppSiteForLink observable collection and loaded(Working fine)
Thanks and Regards
|
|
|
|