|
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
|
|
|
|
|
Why are you binding your TextBox 's Text property to a ObservableCollection<string> ?
"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"
|
|
|
|
|
Rather binding Textbox's text property to ObservableCollection I would suggest create string property and binding it with text property of "txtSearchAppSite" and on basis of that value you can write logic to change the value of "txtStatus" and "txtDescription".
Let me know if it works for you.
Regards
|
|
|
|
|
what is Silver Light ??? and Purpose actully where it use..
|
|
|
|
|
Forget it, Silverlight is a deprecated framework and has no future use.
It was framework that allowed a developer to use a single technology to deploy responsive web applications that rivalled the desktop user experience. We are left with a dogs breakfast of different frameworks, scripts, CSS and javascript FFffaaaaarrrrkkkkkk!!!!!!!!!!!!!!
Never underestimate the power of human stupidity
RAH
|
|
|
|
|
Hi,
I have a problem setting an image to a nested menu item (sub menu).
On top level it is working:
<Menu SnapsToDevicePixels="True" VerticalAlignment="Top">
<MenuItem Header="File">
<MenuItem.Icon>
<Image Source="{Binding ElementName=imgTest, Path=Source}"/>
</MenuItem.Icon>
</MenuItem>
</Menu>
The Image and the text are shown.
Now I do:
<Menu SnapsToDevicePixels="True" VerticalAlignment="Top">
<MenuItem Header="File">
<MenuItem Header="Exit">
<MenuItem.Icon>
<Image Source="{Binding ElementName=imgTest, Path=Source}"/>
</MenuItem.Icon>
</MenuItem>
</MenuItem>
</Menu>
The sub menu is shown without the image. What do I am missing.
In both cases imgTest is defined as:
<Image Margin="3, 3, 3, 3" Name="imgTest">
<Image.Source>
<DrawingImage>
<DrawingImage.Drawing>
<GeometryDrawing Brush="#FF000000" Geometry="M48.915604,39.796998L49.232002,41.73309 18.511999,46.738 18.197001,44.801911z M26.696344,37.951999C27.351365,40.044217,30.231,41.092324,30.231,41.092324L25.910998,42.530999z M26.878857,31.266772L26.9972,33.22778 15.219097,34.475999 15.012001,32.525582z M34.563435,20.119521L32.862622,22.185774 12.228199,23.391999 12.115,21.430711z M36.7463,10.928L36.801003,12.889913 9.3190308,13.674999 9.2630005,11.713086z M48.612541,6.759L48.645159,6.8475333C49.62698,9.3927367,51.956423,12.657845,56.185604,13.352003L56.397999,13.383851 37.033453,37.166108 32.585721,37.558 29.444799,34.677852 29.182,30.360229z M39.522339,5.2349992L42.135407,10.839494 40.334999,13.107881 40.304173,13.145332 37.950729,7.982356 4.0573845,8.1138562 14.78915,52.345605 54.832485,45.017514 47.395187,28.701589 49.447243,26.521901 59.413,47.896409 11.255238,57.579999 0,5.3651915z M54.178093,0C62.421474,0.65496874,62.031075,6.8060206,62.031075,6.8060204L58.233984,11.515564C51.559698,11.778664,50.122002,4.972653,50.122002,4.9726532z">
</GeometryDrawing>
</DrawingImage.Drawing>
</DrawingImage>
</Image.Source>
</Image>
Anyone?
I still say the magic word: Immediately! Okay - "please" of course!
Best Regards
Martin
|
|
|
|
|
If I were you, I'd look to convert your image into a Style like this:
<Style x:Key="LocalImageStyle" TargetType="{x:Type Image}">
<Setter Property="FlowDirection" Value="LeftToRight"/>
<Setter Property="Source">
<Setter.Value>
<DrawingImage>
<DrawingImage.Drawing>
<GeometryDrawing Brush="#FF000000" Geometry="M48.915604,39.796998L49.232002,41.73309 18.511999,46.738 18.197001,44.801911z M26.696344,37.951999C27.351365,40.044217,30.231,41.092324,30.231,41.092324L25.910998,42.530999z M26.878857,31.266772L26.9972,33.22778 15.219097,34.475999 15.012001,32.525582z M34.563435,20.119521L32.862622,22.185774 12.228199,23.391999 12.115,21.430711z M36.7463,10.928L36.801003,12.889913 9.3190308,13.674999 9.2630005,11.713086z M48.612541,6.759L48.645159,6.8475333C49.62698,9.3927367,51.956423,12.657845,56.185604,13.352003L56.397999,13.383851 37.033453,37.166108 32.585721,37.558 29.444799,34.677852 29.182,30.360229z M39.522339,5.2349992L42.135407,10.839494 40.334999,13.107881 40.304173,13.145332 37.950729,7.982356 4.0573845,8.1138562 14.78915,52.345605 54.832485,45.017514 47.395187,28.701589 49.447243,26.521901 59.413,47.896409 11.255238,57.579999 0,5.3651915z M54.178093,0C62.421474,0.65496874,62.031075,6.8060206,62.031075,6.8060204L58.233984,11.515564C51.559698,11.778664,50.122002,4.972653,50.122002,4.9726532z">
</GeometryDrawing>
</DrawingImage.Drawing>
</DrawingImage>
</Setter.Value>
</Setter>
</Style>
Then, change your MenuItem.Icon to this:
<Image Style="{StaticResource LocalImageStyle}"/> And that's it - you can reuse your style whereever you like.
|
|
|
|
|
Thanks a lot! Works great!
|
|
|
|
|
|
Possibly related to this SO thread[^] - it's a ContextMenu rather than a Menu , but I suspect the root cause is the same.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
I have a window with 2 anchorable panes (one left and one at the bottom) and a documentPane. I use MVVM.
So I set the DocumentsSource and AnchorablesSource properties of DockingManager. The collection in AnchorablesSource
only binds to the left anchorable pane. I do not how to bind models to the second anchorable
How do I have to set up the xaml so that I have control over the binding of the anchorable panes?
Thanks in advance
Marc
|
|
|
|
|
Overview
I'm writing this Timeline user control[^]
It's internal design looks like this
[^]
Question
There is a timer that moves the InnerCanvas to the left at regular intervals. This is Live mode.
The Now line is a child of the InnerCanvas, so that when the user slides it, the Now line will move also. Once the user slides the InnerCanvas, the control is then in History Mode. A History line appears when the Now line is and the Now line moves right with the timer ticks. So basically the user can see where Now WAS and where it IS relative to the slide amount.
In addition, in Live Mode, when the Now line is 3/4 of the way into the current period (1 Day, 3 Days, 5 Days), then an additional period is added to the right.
The problem is that in Live Mode, the now line should ALWAYS be 200 relative to the right side of the OutterCanvas.
There's got to be a way to know, regardless of the size or position of the InnerCanvas, to position it there.
My first pass was this
private void setupNowLine(double distanceToMove = 0)
{
double left = Canvas.GetLeft(innerCanvas);
if (distanceToMove == 0)
{
distanceToMove = left - originalInnerCanvasLeft;
}
nowLinePosition = (INNER_CANVAS_WIDTH + distanceToMove) - NOW_LINE_POSITION;
Canvas.SetLeft(nowLine, nowLinePosition);
}
But it doesn't work. For the life of me I can't get the calculations right. I could use some help here.
Thanks
If it's not broken, fix it until it is
|
|
|
|
|
Not really an answer, but have you looked at the existing WPF timeline controls to see if any of them do what you need?
Google found these:
along with some commercial options as well.
"These people looked deep within my soul and assigned me a number based on the order in which I joined."
- Homer
|
|
|
|
|
Yes, I've looked at them. They're more complex and I need and in addition I have some special needs that preclude me from using them.
If it's not broken, fix it until it is
|
|
|
|
|
Hello Everyone,
I am working on WPF app and got stucked on below items, any help would be greatly appreciated.
1) I am using usercontrol (do not want to use window) and want to stop resizing of it but cannot see any property. please help me in achieving the same.
2) I have a Grid having rowdefinitions and columndefinitions which is containing multiple button inside it. my task is whenever i am setting the visibility of any button to false that cell space should get released and next button should overcome this position.
Many Thanks
|
|
|
|
|
Without knowing more about your app, I would suggest the following:
1) Set the .VerticalAlignment and .HorizontalAlignment of the user control to something other than "Stretch"
2) To reclaim the space of a "hidden" control, set its .Visibility to "Collapsed". (You may have to also set the .Width of the cell to "Auto")
|
|
|
|
|
Hi Gerry,
Thanks for your quick response.
1) for point 1 , i will check and confirm back to you
2) for point 2 , i cannot see any cell definition in grid , i am using like this
<Grid.ColumnDefinitions>
<ColumnDefinition Width="Auto"/>
<ColumnDefinition Width="Auto" />
</Grid.ColumnDefinitions>
<Grid.RowDefinitions>
<RowDefinition Height="Auto" />
<RowDefinition Height="Auto" />
</Grid.RowDefinitions>
my control is
<textblock textwrapping="Wrap" textalignment="Center" style="{StaticResource TextBlockStyle}">
QC Report
now when i m using the collapsed property of visibility of button, space is not releasing. please suggest.
Regards
|
|
|
|
|
Your "grid" in (2) has only 2 rows, yet your button's .Row is 2 (relative to 0).
I'd correct that before trying other things.
|
|
|
|
|
Hi Gerry,
Sorry , my bad , actually i alter this to set as an example and forget to change the value. Yes you're correct it should be 1. so , bascally i am having 2,2 grid with buttons on every cell. Now please suggest how can i use collapsed property on cell . Thanks
|
|
|
|
|
Show what you've coded; the elements you need have already been discussed.
You should be able to toggle .Visibility in design mode and see the results with a simple grid and some buttons.
|
|
|
|
|